Aloha,

Is this even easier solution only for postgreSQL, or is it for MySQL?
I am going to have to start working with integrating MySQL into zope-based stuff soon so I'm trying to get a head start... :-)

thanks,
John S.

Tino Wildenhain wrote:
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 )


--

John Schinnerer - MA, Whole Systems Design
------------------------------------------
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
[EMAIL PROTECTED]
http://eco-living.net
_______________________________________________
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