RE: [PHP-DB] Retrieve auto_increment value after an insert with ODBC
| From: | John W. Holmes | Date: | Wed, 02 Oct 2002 22:59:43 +0000 |
| Subject: | RE: [PHP-DB] Retrieve auto_increment value after an insert with ODBC | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22177@lists.php.net to get a copy of this message | ||
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:RJameson@usa.ibs.org]
> Sent: Wednesday, October 02, 2002 2:41 PM
> To: php-db@lists.php.net
> 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:wergedor@hotmail.com]
> Sent: Wednesday, October 02, 2002 11:57 AM
> To: php-db@lists.php.net
> 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