[Zope] multiple inserts and MySQLDA

Jorge Magalhaes jmagalhaes@eng.uminho.pt
Sat, 08 Apr 2000 00:59:19 +0100 (WET)


> You can actually nest ZSQL methods in a couple of ways.  First of al, I
> sometimes find it easiest to use a dtml-let to set up the namespace for
> the second query, when doing what you are doing eg:
> 
> <dtml-in qry1>
> <dtml-let value1=var1
>           value2=var2>
> <dtml-in qry2>
> ...
> </dtml-in>
> </dtml-let>
> </dtml-in
> 
> This has always worked for me.  There should be know need to pass
> parameters in explicitly, since dtml-let should put them in the
> namespace.
> 
> HOWEVER, depending on your needs, this is sometime easier.
> 
> ZSQLMethod # 1 (id is qry1)
> 
> SELECT (value1, value2) from table1
> 
> ZSQLMethod # 2 (id is qry2)
> 
> INSERT INTO table2 values 
> <dtml-in qry1>
> <dtml-unless sequence-start>,</dtml-unless>
> (<dtml-var value1>, <dtml-var value2>)
> </dtml-in>

I see (value1=student_id, value2=score ). The value1 coming from the qry1
(OK) but in the qry2 i need to insert for each value1 a new value2. I
think that a need do some modifications. I have tried to substitue 

<dtml-var value2>   for <dtml-sqlvar SCORE type=int> but the qry2
inserting the same value2 for each value1.

Thanks

jorge.
 
> 
> Notice that I am calling the first query directly from the second query,
> which is about as close to nested SELECT statements as you can get in
> MySQL.
> 
> --sam
>