I have a table called BUILD_INFO and it has the following columns:
BUILD_IDBUILD_NAMEDATEUSER
The BUILD_ID is an autoincrement field, so I don’t set it when I do an insert. It’s the primary key that is used to relate this row in this table to other rows in other tables.
When I insert a new row in the BUILD_INFO table, I want to know the BUILD_ID that was set, so I can retrieve it and use it when I add rows in other tables.
I can’t really query it by the other columns because other rows could duplicate these column values. I can’t simply requery the table and pull up the largest BUILD_ID because another user might have inserted a row after I did. It be nice if there was something like a Row Number that I could retrieve and query rows by. Does something like that exist?
I’m writing my script in Perl using the DBI module and my database could be Oracle or MySql.
How can I retrieve the information of the row I just inserted in SQL or in using the Perl DBI module?
But see the caveats in http://p3rl.org/DBI#last_insert_id