sql - How to get ROWID when inserting into table using FORALL and RETURNING -


i rowid of inserted record using returning clause forall insert statement (bulk insert) pl/sql table of records (associative array of records). believe, problem in using table of records in forall , bulk collect together.

see example:

create table test2 (num number); set serveroutput on  declare   type r_rec record (num number, row_id rowid); --  type t_rid table of rowid index binary_integer;   type t_tab table of r_rec index binary_integer;   v_tab     t_tab;   --v_rid     t_rid; begin   v_tab(1).num := 1.11;   v_tab(2).num := 2.22;   v_tab(3).num := 3.33;   --   forall in v_tab.first..v_tab.last     insert test2 (num)     values (v_tab(i).num)     returning rowid bulk collect v_tab(i).row_id   ;   in v_tab.first..v_tab.last   loop      dbms_output.put_line('num/rowid : ' || v_tab(i).num || '/' || v_tab(i).row_id);   end loop; end; / 

it raises error: pls-00437: forall bulk index cannot used in returning clause problem here? need pl/sql table returning rowids?

do need pl/sql table returning rowids?

yes ..you can try below: need collection hold return of rowids since "forall bulk index cannot used in returning clause"

declare   type r_rec record (num number, row_id rowid);    type t_tab table of r_rec index binary_integer;   v_tab     t_tab;    type r_rw table of rowid index pls_integer;    v_rw r_rw;  begin   v_tab(1).num := 1.11;    v_tab(2).num := 2.22;    v_tab(3).num := 3.33;    --   forall in v_tab.first..v_tab.last     insert test2 (num)     values (v_tab(i).num)     returning rowid bulk collect v_rw;    in v_tab.first..v_tab.last   loop      dbms_output.put_line('num/rowid : ' || v_tab(i).num || '/' ||v_rw(i));   end loop;  end; / 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -