我有兩個表名爲 「AA」 和 「AB」PL/SQL - 收集和記錄
- 在表中 「AA」 我有一個像CUST_NO,姓名,地址等欄目..
- 在表「AB」中,我有一列
cuno
我需要從「AA」表中取出cust_no並將其放入「AB」表的cuno列中。
我嘗試了一些代碼在這裏...
declare
Type Ty_Handoff_Pc Is Table Of aa%Rowtype Index By Binary_Integer;
Type sam Is Table Of ab%rowtype;
l_pc Ty_Handoff_Pc;
l_ab sam;
begin
select distinct cust_no bulk collect into l_pc from aa;
for j in 1 .. 10 loop
l_ab(j) := l_pc(j).cust_no;
insert into ab values l_ab(j);
end loop;
end;
在此先感謝
Upvote for INSERT ... SELECT推薦 – 2011-03-30 05:12:48