plsql块报错

JS 2012-09-04 10:29:01

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’类型错误

请说的详细点,谢谢
...全文
147 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fw0124 2012-09-04
  • 打赏
  • 举报
回复
10g上也没问题。。。
JS 2012-09-04
  • 打赏
  • 举报
回复
奇怪啊 我是9i的 应该不是版本问题 没有新东西啊~[Quote=引用 1 楼 的回复:]

SQL code

--经测,没报错,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_2012……
[/Quote]
人生无悔 2012-09-04
  • 打赏
  • 举报
回复

--经测,没报错,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 程序.

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧