declare
rec_1 test_2%rowtype;
rec_2 test_2%rowtype;
type t_tbl is table of test_2%rowtype;
v_tbl_1 t_tbl;
v_tbl_2 t_tbl;
begin
rec_1:=rec_2; ---记录可以互相赋值
v_tbl_1:=v_tbl_2; ---集合可以互相赋值
---select * into rec_1 from test_2 ;----error 实际返回的行数超出了请求行数
select * into rec_1 from test_2 where rownum=1;
select * bulk collect into v_tbl_1 from test_2; ---可以用bulk collect into赋值
rec_1.col_1:=3; ---记录可以用.引用
---v_tbl_1.col_1:=3;---error 必须声明col_1组件
end;
create or replace procedure proc_test is
type t_target_id is table of varchar2(50);
v_target_id t_target_id:=t_target_id();
begin
select target_id bulk collect into v_target_id from tm_table_sources;
insert into test_table(target_id)
select * from table(v_target_id);----error sql语句中不能使用本地收集变量
commit;
end proc_test;
把type t_target_id is table of varchar2(50);====》create type t_target_id is table of varchar2(50);
就好了,因为sql语句中的类型必须要是schema级别的。