-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Luis Cortes Sent: Monday, April 17, 2000 2:19 PM To: zope@zope.org Subject: [Zope] MySql and Auto_increment
Hello,
Has anyone run into this problem: I have created a table with an auto_increment id. I want to be able to get the new id without having to do another query. Does someone know how to do this with Mysql?
I.E.
create table test( id NOT NULL auto_increment, name char(20))
insert into table test (name) values ("first");
If your inserting from a SQL Method you can add the following after the insert statement: <dtml-var sql_delimiter> select LAST_INSERT_ID() as newid The method will return just like any other select SQL method with the auto number in 'newid'. I don't know, however, if there is a race issue if this is called by more than one client at "the same time" where one might end up getting the other's 'newid', since the ID is kept per connection. Anyone know if this is a problem? _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com