Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

get sequence number for a row just inserted?

 
   Database Help (Home) -> Oracle RSS
Next:  Cannot install Enterprise Manager  
Author Message
mh

External


Since: Jan 09, 2008
Posts: 131



(Msg. 1) Posted: Thu Dec 11, 2008 6:28 pm
Post subject: get sequence number for a row just inserted?
Archived from groups: comp>databases>oracle>misc (more info?)

What's the most canonical way get the autoincremented sequence number of a
row I just inserted?

--
Mark Harrison
Pixar Animation Studios

 >> Stay informed about: get sequence number for a row just inserted? 
Back to top
Login to vote
Malcolm Dew-Jones

External


Since: Aug 05, 2003
Posts: 305



(Msg. 2) Posted: Thu Dec 11, 2008 6:28 pm
Post subject: Re: get sequence number for a row just inserted? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

mh DeleteThis @pixar.com wrote:
: What's the most canonical way get the autoincremented sequence number of a
: row I just inserted?


Use the RETURNING clause.

 >> Stay informed about: get sequence number for a row just inserted? 
Back to top
Login to vote
DA Morgan

External


Since: Dec 14, 2007
Posts: 757



(Msg. 3) Posted: Thu Dec 11, 2008 6:28 pm
Post subject: Re: get sequence number for a row just inserted? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

mh.TakeThisOut@pixar.com wrote:
> What's the most canonical way get the autoincremented sequence number of a
> row I just inserted?

Two ways: One is to use CURRVAL
http://www.psoug.org/reference/sequences.html

The other the RETURNING clause
http://www.psoug.org/reference/insert.html
http://www.psoug.org/reference/update.html
http://www.psoug.org/reference/delete.html
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan.TakeThisOut@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
 >> Stay informed about: get sequence number for a row just inserted? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Return multiple copies of same row in table with sequence .. - I want to return multiple copies of data from a table but do not understand how to accomplish this. The following code works to return a fixed number of copies but I cannot determine how to replace the constant with a variable. How do I do this and is....

setting currval in a sequence without recreating the seque.. - Can you set the currval in a sequence without having to drop and recreate the sequence? I rather not have to drop and recreate something because I have to do a lot more paperwork. Can't we just use alter or update? please provide example.

Getting reference from a newly inserted object - HI I am troubling in getting reference of an user defined type after inserted it into a table. For example, I use a java program to insert an user defined object: .. .. .. OraclePreparedStatement pstmt = (OraclePreparedStatement)conn.prepareStatement..

how to refresh a sequence - How could I refresh a sequence in Oracle using an SQL statement? I've got the problem, that the current number of a sequence is less the highest index in a table, where I want to use the sequence. Regards, Robert

Sequence Numbers Jumping - We are migrating an application from Oracle 9 to Oracle 10. The application uses several sequence objects for user visible sequences. For some reason on Oracle 10 the sequences are jumping. I've checked that the sequences are defined as ordered and..
   Database Help (Home) -> Oracle All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]