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

编程学习 2021-07-05 16:08www.dzhlxh.cn编程入门
在oracle使用中为了提高取数据效率,本文将详细介绍Oracle BULK COLLECT批量取数据,需要了解跟多的朋友可以参考下
代码如下:

-- 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;

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板