declare TYPE emp_table_type is table of tbl_emp.n_emp_id%type INDEX BY BINARY_INTEGER; emptable emp_table_type; begin select n_emp_id bulk collect into emptable from tbl_emp where n_emp_id=999; insert tableA select * from emptable; update tableB set xx=xx where id in (select n_emp_id from emptable);
------解决方案-------------------- declare TYPE emp_table_type is table of tbl_emp.n_emp_id%type INDEX BY BINARY_INTEGER; emptable emp_table_type; begin select n_emp_id bulk collect into emptable from tbl_emp where n_emp_id=999; for i in 1..emptable.count() loop insert INTO tableA(id) VALUES(emptable(i)); update tableB set xx=xx where id =emptable(i); end loop; end;
------解决方案-------------------- 表变量主要用于循环操作。集合变量。
或者 你的需要根本不要定义表变量。 insert into tableA select n_emp_id from tbl_emp where n_emp_id=999; update tableB set xx=xx where id in (select n_emp_id from tbl_emp where n_emp_id=999 );