为什么我的cursor只能取两个字段的值

[复制链接]
查看11 | 回复9 | 2006-6-20 14:34:17 | 显示全部楼层 |阅读模式
我在form中写produce,定义cursor c_qty is select column1,column2,column3------from view ,执行时系统报错,ora-01001,而当我重新定义cursor is c_qty is select column1,column2 from view时,运行正常。这到底是怎么回事,前一天运行还好,请高手帮忙。
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
have you opened the cursor before fetching data and closed the cursor after using?
paste code if still problems.
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
你的view中有column3吗?
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
原代码:
cursor c_qty is
select part_name,code_type,count,sum(sz_qty),sum(fh_qty)

from v_boss_produce

where to_char(io_date,'yyyymmdd') between 20070105 and 20070107

group by part_name,code_type,count;
我使用游标正常,只要我只取上述代码中的任意两个字段就没问题,但取三个以上就出错
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
奇怪 现在报错ora-00934
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
自己顶,大家都没遇到这样的问题吗? 真是奇怪了,随便查询任何一个表,只要取了三个以上的字段就报错,而且错误不定,又遇到了ora-00937的错误,我估计跟数据库有关,但不知道是怎么回事.
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
可以呀。9.2.0.5.0
declare
cursor cur is select empno,ename,deptno,sal from scott.emp;
v_empno number;
v_ename varchar2(10);
v_deptno number;
v_sal number;
begin
opencur;
loop
exit when cur%notfound;
fetch cur into v_empno,v_ename,v_deptno,v_sal;
dbms_output.put_line(v_empno||' '||v_ename||' '||v_deptno||' '||v_sal);
end loop;
close cur;
end ;
/

7369 SMITH 20 800
7499 ALLEN 30 1600
7521 WARD 30 1250
7566 JONES 20 2975
7654 MARTIN 30 1250
7698 BLAKE 30 2850
7782 CLARK 10 2450
7788 SCOTT 20 3000
7839 KING 10 5000
7844 TURNER 30 1500
7876 ADAMS 20 1100
7900 JAMES 30 950
7902 FORD 20 3000
7934 MILLER 10 1300
7934 MILLER 10 1300
PL/SQL procedure successfully completed
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
写的好
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
你查查ORACLE里帮助里的ora-00934这个错误是怎么描述的
回复

使用道具 举报

千问 | 2006-6-20 14:34:17 | 显示全部楼层
没看过这么奇怪的问题,如果不用cursor,直接查询,有没有问题呢?
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行