I have a table in Oracle DB with a Primary Key that gets populated on Insert by a trigger on the table - the trigger gets the next sequence number from a sequence I created for the table and uses that for the value of the PK on insert. Now I would like to be able to return that PK value from my insert statement and use it as Foreign Key in another (child) table. All of that is done in VB code, not a Stored Procedure.
Is there some combination of Insert statement that returns PK used in that Insert? From the same transaction?
I know I can do: [tt]Select Max(PK_Field) as MyPKValue from SomeTable[/tt], but this way I may get somebody else's PK, not necessary mine (if somebody else issued another Insert statement). The same goes if I ask for current value from my sequence, not very safe bet either.
Have fun.
---- Andy
There is a great need for a sarcasm font.
Is there some combination of Insert statement that returns PK used in that Insert? From the same transaction?
I know I can do: [tt]Select Max(PK_Field) as MyPKValue from SomeTable[/tt], but this way I may get somebody else's PK, not necessary mine (if somebody else issued another Insert statement). The same goes if I ask for current value from my sequence, not very safe bet either.
Have fun.
---- Andy
There is a great need for a sarcasm font.