[RESOLVED] Retrieving the autogenerated key while doing an INSERT?
Hey there. I've currently got this SQL statement:
INSERT INTO Inlagg (rubrik, anvandare, inlaggText) VALUES ('" + rubrik +"', '" + anvandare.getAnvandarnamn() + "', '" + inlaggText + "')"
I've set it up to autogenerate a key when a row is inserted into the table. My problem now is that I need to use this key immediately after inserting the row, is there any way to insert the row and retrieve the autogenerated key in one go?
Im using Java (So I guess its ...JDBC?) and an Access 2002 database.
Help would be much appreciated. Thanks.
Re: Retrieving the autogenerated key while doing an INSERT?
You can't get it in the same statement (unless JDBC offers that feature, but I doubt it), but can in a separate statement which is reliable, as shown in the FAQ How can I get the auto-generated AutoNumber/Identity value for the record just added?
Re: Retrieving the autogenerated key while doing an INSERT?