错误
ORA-06504: PL/SQL: 结果集变量或查询的返回类型不匹配
ORA-06512: 在line 9
代码如下:
declare
type cur is ref cursor;
yy cur;
xx emp.ename%type;begin
open yy for select a2.* from (select * from (select emp.ename,rownum rn from emp order by sal) a1 where a1.rn>7) a2 where a2.rn<9;
fetch yy into xx;
while yy%found loop
dbms_output.put_line('显示'||xx);end loop;
close yy;
end;其中 select a2.* from (select * from (select emp.ename,rownum rn from emp order by sal) a1 where a1.rn>7) a2 where a2.rn<9; 此句是从emp表中,选出位置序号是8的记录。
ORA-06504: PL/SQL: 结果集变量或查询的返回类型不匹配
ORA-06512: 在line 9
代码如下:
declare
type cur is ref cursor;
yy cur;
xx emp.ename%type;begin
open yy for select a2.* from (select * from (select emp.ename,rownum rn from emp order by sal) a1 where a1.rn>7) a2 where a2.rn<9;
fetch yy into xx;
while yy%found loop
dbms_output.put_line('显示'||xx);end loop;
close yy;
end;其中 select a2.* from (select * from (select emp.ename,rownum rn from emp order by sal) a1 where a1.rn>7) a2 where a2.rn<9; 此句是从emp表中,选出位置序号是8的记录。
解决方案 »
- PLSQL导入数据库总是失败。。。。
- oracle中两张不同结构的表(部分字段相同)数据导入
- oracle10 stream问题求教?
- 求pro*c/C++ 编绎生成 cpp文件的脚本啊. 急~~~
- 在JAVABEAN中调用存储过程出现了错误,请达人指点一下。在线等。
- 如何修改表中一个字段的值不能重复?
- oradebug 如何用?
- 急救oracle Imp 与Exp 问题???
- 如何将SQLSERVER中的表,数据,存储过程导入到ORACLE中啊?
- 怎样配置thin方法连接数据库!
- 我的机器是win7 64位,现在想要安装一个oracle9可是网上找不到资源啊
- 不安装oracle客户端,连接oracle可行么?
rownum 每次分配都是从1开始分配的
select * from (
select emp.ename,row_number() over(order by sal )rn from emp
) a1 where a1.rn>7
) a2 where a2.rn<9;
参考 http://www.cnblogs.com/xiekeli/archive/2009/04/02/1643329.html
它的查询结果是2列数据
而select a2.* from ...之后的结果应该也是2列数据
也就是说游标是指向2列数据的
fetch yy into xx(xx使用xx emp.ename%type定义的应该是1列数据)把2的数据指向赋值给1列的接收变量?这样可以吗?我也是刚刚开始学Oracle的~若理解不当还请见谅!