> I have a table that includes an auto_increment field. > > This is used to build up an audit trail of the passage of a file through > my > server. As a file is received from a remote system I create the first > entry > for that file in the audit trail table. I build up an sql INSERT command > (I'm > updating the table using Perl and DBI) using information about the file - > it's name, the IP address of the sending machine and so on. > > What I want to do is immediately retrieve or otherwise have returned to my > perl program the value of the auto increment field for the newly added > row. > > It is possible (indeed likely) that multiple processes might be updating > the > table at the same time.
Issue a SELECT LAST_INSERT_ID() query after you do your INSERT to get the number back. The ID returned will be specific for the connection, so multiple INSERTs won't be a problem. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php