We would like to return ids inserted from an insert statement that has a 'select from' clause as its source of values.
Example:
Create table Table1 (Col1 Number)
declare
vId number;
begin
insert into Table1 (select 1 from dual)
returning COL1 into vId;
end;
Error:
ORA-06550: line 5, column 5:
PL/SQL: ORA-00933: SQL command not properly ended
Is there something missing in the syntax, is it possible to do this? Thank you.
returning into
doesn't work withINSERT INTO SELECT *
. You should use aFORALL
block for that. See this or this – Kaushik Nayak