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.

Regards
Tino
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to