Get ID of last inserted record in oracle db

后端 未结 1 1615
南笙
南笙 2020-12-01 10:36

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?

1条回答
  •  粉色の甜心
    2020-12-01 11:25

    Use the PL/SQL RETURNING clause:

    insert into mytable (...) values (...)
    returning id into v_id;
    

    0 讨论(0)
提交回复
热议问题