[Zope] ZSQL Method Question

Tino Wildenhain tino at wildenhain.de
Tue Jul 18 04:59:07 EDT 2006

Peter Bengtsson wrote:
> What if you have 1,000,000 requests/sec?
> What if between the INSERT and the LAST_INSERT_ID() another INSERT is made?
> I use PostgreSQL and with postgres you can always ask the sequence what
> the next id is going to be. It goes something like this::
> next_id = context.GetNextId()[0].next_id
> context.SQLInsertUser(uid=next_id, name='Peter')
> where 'GetNextId' is a ZSQL method that looks like this::
> <params></params>
> SELECT NEXTVAL('users_uid_seq') AS next_id

Its even easier:
one ZSQL Method:

INSERT INTO foo (foo_id,blah,bar) VALUES
(nextval('foo_foo_id_seq'),<dtml-sqlvar blah> ... );
SELECT CURRVAL('foo_foo_id_seq') as foo_id;

But your above solution is valid too.


More information about the Zope mailing list