|
-
Dec 9th, 2008, 12:09 PM
#1
[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.
-
Dec 9th, 2008, 12:15 PM
#2
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?
-
Dec 10th, 2008, 07:22 AM
#3
Re: Retrieving the autogenerated key while doing an INSERT?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|