Search notes:

Oracle: identity columns - RETURNING clause

create table tab_with_id (
   txt  varchar2(20),
   id   integer generated always as identity
);

declare

   procedure ins(t varchar2) is
      inserted_id pls_integer;
   begin
      insert into tab_with_id (txt) values (t) returning id into inserted_id;
      dbms_output.put_line(t || ' was inserted with id ' || inserted_id);
   end ins;

begin
   ins('foo');
   ins('bar');
   ins('baz');
end;
/

drop table tab_with_id;
Github repository Oracle-Patterns, path: /DatabaseObjects/Tables/columns/identity/returning.sql

RETURNING clause in an INSERT … SELECT FROM statement

It seems that it is not possible to combine an insert statement with a returning into. The demonstration below produces an ORA-00933: SQL command not properly ended error.
create table tq84_identity (
    id   integer generated always as identity,
    txt  varchar2(100)
);

declare
   i  integer;
begin
   insert into tq84_identity(txt)
   select dummy from dual
   returning id into i;
   
   dbms_output.put_line('id = ' || i);
end;
/

See also

Identity columns
PL/SQL: returning into clause

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206647, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/objects/tables/columns/identity/returning-into(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78