不能用游标(CURSOR),因为数据一旦比较多,Result.Next的时候,就花费比较多的时间了。
所以想在存储过程中直接返回一个二维数组。比如:
原始的SQL为select A,B,C from TestTBL;查到N条数据,想把结果存储到一个二维数组 TArray里面,数组格式为
TArray(0)(0) = A
TArray(0)(1) = B
TArray(0)(2) = C
TArray(1)(0) = A
TArray(1)(1) = B
TArray(1)(2) = C
...
TArray(N-1)(0) = A

解决方案 »

  1.   

    1、百度一下返回值类型为嵌套表的函数。2、不用1就只能用游标变量了 sys_refcursor.
      

  2.   

    lz可以用复合数据类型来实现
    CREATE OR REPLACE TYPE testtbl_table_type IS TABLE OF testtbl%ROWTYPE;
    /
    declare
    testtbl_table testtbl_table_type:=testtbl_table_type();
    begin
    for c_testtbl in (select A,B,C from TestTBL) loop
    testtbl_table.extend;
    testtbl_table(testtbl_table.count).a:=c_testtbl.a;
    testtbl_table(testtbl_table.count).b:=c_testtbl.b;
    testtbl_table(testtbl_table.count).c:=c_testtbl.c;
    end loop;
    end;