2.使用BLUK COLLECT一次取出一个数据集合,比用游标条取数据效率高,尤其是在网络不大好的情况下。但BLUK COLLECT需要大量内存。
使用例子:
(1)定义一个TABLE
CREATE OR REPLACE TYPE string_table AS TABLE OF VARCHAR2(100);
(2)在存储过程里面测试
DECLARE
v_table string_table;
BEGIN
SELECT cust_name
BULK COLLECT INTO v_table
FROM cust c
WHERE c.cust_id BETWEEN 64561 AND 64565;
FORALL idx IN 1..v_table.COUNT
INSERT INTO cust_test VALUES(v_table(idx));
COMMIT;
END;