17,089
社区成员
发帖
与我相关
我的任务
分享
declare
type tt_type is record
(
col1 test_20120816.col1%type,
col2 test_20120816.col2%type,
col4 test_20120816.col4%type
);
type tt_table is table of tt_type;
tt_tab tt_table;
cursor tt_cur is select col1,col2,col4
from wangx.test_20120816 where col1=1;
begin
open tt_cur;
fetch tt_cur bulk collect into tt_tab;
for i in tt_tab.first..tt_tab.last
loop
dbms_output.put_line(tt_tab(i).col1||' '||tt_tab(i).col2);
end loop;
close tt_cur;
end;
/
报错信息:fetch tt_cur bulk collect into tt_tab; --‘tt_tab’类型错误
请说的详细点,谢谢
--经测,没报错,oracle 11g r2 sql*plus
SQL> create table test_20120816(col1 int,col2 int,col4 int);
已建立表格.
SQL> insert into test_20120816 values(1,1,1);
已建立 1 個資料列.
SQL> insert into test_20120816 values(1,2,3);
已建立 1 個資料列.
SQL> declare
2 type tt_type is record
3 (
4 col1 test_20120816.col1%type,
5 col2 test_20120816.col2%type,
6 col4 test_20120816.col4%type
7 );
8 type tt_table is table of tt_type;
9 tt_tab tt_table;
10 cursor tt_cur is select col1,col2,col4
11 --from wangx.test_20120816 where col1=1;
12 from test_20120816 where col1=1;
13 begin
14 open tt_cur;
15 fetch tt_cur bulk collect into tt_tab;
16 for i in tt_tab.first..tt_tab.last
17 loop
18 dbms_output.put_line(tt_tab(i).col1||' '||tt_tab(i).col2);
19 end loop;
20 close tt_cur;
21 end;
22 /
1 1
1 2
已順利完成 PL/SQL 程序.