请问高手们:
在ORACEL9i 下。用 fetch bulk collect into 可以同时取多个字段吗
例如:
open testcur for 'select a,b,c from test ';
fetchtestcur bulk collect intorecordTable;
这样行吗?
可以,eg:
[php]
declare
v_ref sys_refcursor;
type toms_type is table of toms%rowtype;
v_toms toms_type := toms_type();
begin
open v_ref for 'select * from toms';
fetch v_ref bulk collect into v_toms;
dbms_output.put_line('bulk collected: ' || v_toms.count);
end;
/
[/php]
谢谢 Toms_Zhang,但是怎么这样就不行呢?
declare
v_ref sys_refcursor;
type tEmp is record
( eno number(4),
ename varchar2(10));
type toms_type is table of tEmp;
v_toms toms_type := toms_type();
begin
open v_ref for 'select empno,ename from emp';
fetch v_ref bulk collect into v_toms;
dbms_output.put_line('bulk collected: ' || v_toms.count);
end;
最初由 llkyq 发布
[B]版本: oracle 9.2.0.1.0 [/B]
这个版本可能不行
PLS-00597 expression string in the INTO list is of wrong type
Cause: This exception is raised for the following errors:
the expression in INTO clause of OPEN or RETURNING statement is neither of legal SQL datatypes nor of PL/SQL RECORD datatype
a collection of records is used in INTO clause of OPEN or RETURNING statement.
a record or a collection of records is used in BULK COLLECT INTO
Action: Use expression with correct datatype in the INTO clause.