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... :-)

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::

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.

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )


John Schinnerer - MA, Whole Systems Design
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to