27

I want to retrieve the id of a newly inserted record with an auto incrementing id column (using the sequence and trigger method). What is the standard way to do this?

haymansfield
  • 5,110
  • 4
  • 33
  • 51

1 Answers1

37

Use the PL/SQL RETURNING clause:

insert into mytable (...) values (...)
returning id into v_id;
Tony Andrews
  • 126,319
  • 20
  • 218
  • 255