[Zope] ZSQL retreive auto_increment id inserted [Q]

Anthony Baxter Anthony Baxter <anthony@interlink.com.au>
Wed, 17 Nov 1999 15:17:17 +1100


>>> Sam Gendler wrote
> I didn't take a long look, but it looks as though this solution requires
> you to call a separate ZSQL query in order to retrieve the ID.  Needless to
> say, there is a wide open race condition if someone else inserts another
> entry before you get the results from the second query. I was looking for
> something that returns the last_insert_id as the result set to an INSERT
> query, much the way the apis (for mysql anyway) do in other environments.
> Please correct me if I am wrong.  Thanks for the effort, anyway

What I do with Oracle and Sequences is have multiple ZSQL methods: the 
first looks up the next value:

select sequence_name.nextval from dual

I take this number back, and use it in subsequence DTML and SQL code.