Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to return ID after inserting into table?

Robin BijuMay 9 2022

Hi, I'm inserting some data into table1 from table2 using the query below inside plsql.
insert into table1 (
col1
, col2
, clo3
)
select
col1
, col2
, col3
from table2;

I want to return the ID of newly inserted row from table1.
I tried,
'RETURNING ID INTO VARIBLAE'. But this is not working in 'insert into select' query.
Is there any other way?

Comments
Post Details
Added on May 9 2022
8 comments
42,560 views