欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle BULK COLLECT批量取数据解决方法

程序员文章站 2023-11-05 16:52:46
复制代码 代码如下: -- created on 2010/11/04 by wangnan declare -- local variables here i integ...
复制代码 代码如下:

-- created on 2010/11/04 by wangnan
declare
-- local variables here
i integer;
type t_table is table of varchar2(10 ) index by varchar2 (2);
v_t_table t_table;

type t_pg3 is table of asis.pg3_agentcd_conversion% rowtype;
v_pg3_table t_pg3;

c_pg3_vendor com.cref;
v_str varchar2( 250);
begin
-- test statements here
open c_pg3_vendor for select * from asis.pg3_agentcd_conversion;

fetch c_pg3_vendor bulk collect into v_pg3_table;
for i in 1 .. v_pg3_table.count loop
v_t_table(v_pg3_table(i).asis_agent_cd) := v_pg3_table(i).tobe_vendor_cd;
end loop;

v_str := v_t_table.first;
while v_str is not null loop
dbms_output.put_line(v_str || ' : ' ||v_t_table(v_str));
v_str := v_t_table.next(v_str);
end loop;

exception when others then
dbms_output.put_line( sqlerrm);
end;