Oracle - Get the last inserted id how-to

Just simple, declare a variable with that type, mostly number, then   use the 'returning' syntax   for that.

set serveroutput on
declare
 nr_id number;
begin
 insert into employees( id, name, age )
 values( seq_employees.NEXTVAL, 'Jones', 33 )
 returning id into nr_id;
 dbms_output.put_line( 'nr_id = ' || nr_id );
end;
/


Hope this helps. 


- Toytoy Gogie

Comments

Popular posts from this blog

LVM: How to remove a volume using pvremove

Use Shell Editor for Eclipse for editing bash, ksh, csh in Unix/Linux system

pdftotext not found in CentOS