无效的游标???高手请进……急!!

[复制链接]
查看11 | 回复2 | 2010-1-4 08:33:08 | 显示全部楼层 |阅读模式
在开发过程中 需要用到动态游标 但使用时出错如下:
1declare
2 TYPE CurTyp IS REF CURSOR;
3 test_cv CurTyp;
4 type idType is table of test1.id%type;
5 type descType is table of test1.description%type;
6 v_id idType;
7 v_desc descType;
8 sqlStmt varchar2(100);
9BEGIN
10 sqlStmt := 'SELECT id,description FROM test1';
11 OPEN test_cv FOR sqlStmt;
12 FETCH test_cv bulk collect INTO v_id,v_desc;
13* END;
14/
declare
*
ERROR 位于第 1 行:
ORA-01001: 无效的游标
ORA-06512: 在line 12
回复

使用道具 举报

千问 | 2010-1-4 08:33:08 | 显示全部楼层
1declare
2 TYPE CurTyp IS REF CURSOR;
3 test_cv CurTyp;
4 type idType is table of test1.id%type;
5 type descType is table of test1.description%type;
6 v_id test1.id%type;
7 v_desc test1.description%type;
8 sqlStmt varchar2(100);
9BEGIN
10 sqlStmt := 'SELECT id,description FROM test1';
11 OPEN test_cv FOR sqlStmt;
12 FETCH test_cv INTO v_id,v_desc;
13* END;
SQL> /
PL/SQL 过程已成功完成。
回复

使用道具 举报

千问 | 2010-1-4 08:33:08 | 显示全部楼层
如果不使用动态游标也不会出错?????
呜呼……
可我又一定需要动态游标和BULK COLLECT
我该怎么办???
1declare
2 TYPE CurTyp IS REF CURSOR;
3 test_cv CurTyp;
4 type idType is table of test1.id%type;
5 type descType is table of test1.description%type;
6 v_id idType ;
7 v_desc descType ;
8 sqlStmt varchar2(100);
9BEGIN
10 --sqlStmt := 'SELECT id,description FROM test1';
11 OPEN test_cv FOR SELECT id,description FROM test1;
12 FETCH test_cv BULK COLLECT INTO v_id,v_desc;
13* END;
SQL> /
PL/SQL 过程已成功完成。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行