[Zope] several SQL statements passing results in a ZSQL method

Renaud Guérin rguerin@free.fr
Thu, 21 Mar 2002 22:37:15 +0100


Le Jeudi 21 Mars 2002 17:40, Matthew T. Kromer a écrit :
> But if you always issue a LOCK TABLE before SELECT MAX from... your
> LOCKs will compete against themselves, so you'll be safe.

Exact, this may save my day ! :)
One last problem though:
How do I pass the id value from the SELECT to the INSERT, and then return 
that to the caller of the ZSQL method.

I tried : SELECT max(id)+1 as new_id ...
and then
INSERT INTO table VALUES (<dtml-var new_id>,....)

but it complains about new_id not declared as an input variable.

If I do INSERT INTO table VALUES (SELECT ...,....) , will I have new_id as a 
returned result ?

thanks