This is not a safe way to do it unless you are locking the table,
getting max value, doing insert with value retrieved, and then unlocking
table. Reason being is that two scripts (or more) running at the same
time can retrieve the same max() value and try to insert it.

---John Holmes...

> -----Original Message-----
> From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 02, 2002 2:41 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Retrieve auto_increment value after an insert
with
> ODBC
> 
> You can select max(aifield) immediately after the insert. :-)
> 
> <>< Ryan
> 
> -----Original Message-----
> From: Stéphane [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 02, 2002 11:57 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Retrieve auto_increment value after an insert with
> ODBC
> 
> 
> Hi,
> 
> I use php and db2 database. I wonder if there is a way  to retrieve
the
> value of an auto-increment id after an insert query.
> (Like mysql_insert_id on MySQL database.)
> The temporary solution is to select record with the same values than
the
> insert.
> 
> Any others solutions?
> 
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to