Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle SQL Statement

Status
Not open for further replies.

SQLReaver

Programmer
May 20, 2000
7
0
0
US
Hi,
I'm wondering, how would you get the identifier ( or the primary key) of the recordset you just inserted without doing a SELECT statement that attempts to check it up by its other characteristics (in Oracle 8)? The reason why I ask is because the recordset I just inserted might not have other characteristics that are unique - except for its identifier which is unique. I do not want to grab the last recordset either because I might end up grabbing another recordset that was inserted at approximately the same time. Thanks in advance. [sig][/sig]
 
Hi SQLReaver,

You might like to ask your question in the Oracle 8 forum if you have an Oracle specific question. I'm sure it's possible by the way, you can query the Oracle data dictionary to pick up this type of information. [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br> [/sig]
 
Hmm, that's a hard one. I'm not aware that Oracle, or any other DBMS for that matter, keeps a record of which session inserted or updated a record. Probably it would be possible to figure this out from the redo log, but that information isn't available inside an application program.

In my opinion this type of functionality has to be built in at the application level. Perhaps you could add a column to your table(s) called &quot;last_update_id&quot; and populate it as you go. Then the query would be something like

select max(record_key) from my_table
where last_update_id = 'my_id'; [sig][/sig]
 
I am not real familiar with this, but I do know that at one point we had some &quot;mysteriously&quot;, ie no one taking credit, deleted or altered records. At that time our DBA turned on Oracle 7.3.4's Audit Trail and was able to figure out which user needed to be retrained in the proper way of processing records. You might want to look into that and see what sort of information is audited.

Sorry that it is not &quot;the&quot; answer, but hope it points you closer to it...
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Sometimes triggers are used to return info about the
record inserted. [sig]<p>Jim<br><a href= > </a><br>oracle, vb, some javascript[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top