We have a table 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 we created for the table and uses that for the value of the key on insert. Now we would like to be able to return that value in our insert procedure (PL\SQL), similar to select @@scope_identity in SQL Server. I have been googling all day and basically come up with nothing - anyone been successful with this before?
Thanks
I don't know if it works with triggers but the RETURNING clause may be what you're looking for:
INSERT INTO my_table (col_1, col_2)
VALUES ('foo', 'bar')
RETURNING pk_id INTO my_variable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With