When I insert a row into a table, there is a primary key generated automatically. I need to know that primary key before commit the transaction.
Currently, I'm using a second select statement (something like: select max(pk) from table_name) to get the primary key just created.
It works fine as long as I have a correct isolation level setting(e.g., SERIALIZABLE).
Is there a way to make the insert statement return me the primary key for the row just inserted? I'm using MySQL with plain SQL.
This is a SQL question, not
JDBC.