Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting ID of inserted record regardless of sequence

728400Oct 16 2009 — edited Oct 19 2009
Hello,

I have a problem finding out how to do this. Maybe someone here will know?

I have class who contain a method which executes insert and update statements. The class returns the ID of the newly inserted record regardless of the table.column name. I can do this with @@identity because I am currently on an MS Access database.
Oracle is another matter. I have figured out that a sequence will give me the nextVal just before I insert the new record so I can have the next ID added in the insert. But how do I write a query that returns the ID of the inserted record regardless of the sequence name? Is it impossible to do that?

Basically I have a function which takes an SQL-string as argument and which returns the ID of the record to be added:
intID = execQuery(strSQL)

Something that makes the matter worse is that the ID column is called something different in every table.

Mattias
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2009
Added on Oct 16 2009
9 comments
1,798 views