Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to get back the inserted row?

Re: How to get back the inserted row?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 05 Jan 2000 14:20:04 -0500
Message-ID: <t6677scbn19g3c75bi2373juodh3d4sejp@4ax.com>


A copy of this was sent to sriniv79_at_hotmail.com (if that email address didn't require changing) On Wed, 05 Jan 2000 18:44:15 GMT, you wrote:

>What is the best way to get the newly created row immediately after an
>insert? I am interested in getting the values of some columns filled in
>by an Insert Trigger.
>

look at the RETURNING clause of the insert/update statements (available with 8.0 and up)

tkyte_at_8.0> create table t ( a int, x date default sysdate );

Table created.

tkyte_at_8.0>
tkyte_at_8.0> declare
  2 l_date date;
  3 begin
  4 insert into t (a) values ( NULL ) returning x into l_date;   5
  5 dbms_output.put_line( l_date );   6 end;
  7 /
05-JAN-00 PL/SQL procedure successfully completed.

>TIA.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Jan 05 2000 - 13:20:04 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US