oracle cursor问题

qq3895 2013-07-12 12:52:05
declare
cursor cr1 is select Avgsalary
from (select E.grade,
E.TestLevel,
(select AA * 2 BB
from (select avg(Salarys) AA
from andy_shen_salary_information S)) Avgsalary
from andy_shen_emp_infomation E
where E.GRADE >= 5
and E.Grade <= 7
and E.TestLevel > 4);
i cr1%rowtype;
begin
open cr1;
for i in cr1 loop
select decode(AA,' ',i.Avgsalary),Salarys,salarymonth,Id from (select A.*, ' ' AA from andy_shen_salary_information A where Id in
(select empid from andy_shen_emp_infomation E where E.GRADE >= 5 and E.Grade <= 7 and E.Testlevel > 4)
and A.SALARYMONTH=6) where AA =' ';
end loop;
close cr1;
end;

这段语句报ora-06550:line-22,column 4:
pls 00428:an INTO clause is expected in this SELECT statement的错误
求解!!!!
...全文
128 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq3895 2013-07-16
  • 打赏
  • 举报
回复
他也只能返回多行单列,现在主要是多行多列,貌似bulk collect 行不通吧
nohandsome 2013-07-12
  • 打赏
  • 举报
回复
在select into语句中使用bulk collect 代码如下: DECLARE TYPE sallist IS TABLE OF employees.salary%TYPE; sals sallist; BEGIN SELECT salary BULK COLLECT INTO sals FROM employees where rownum< 1000--接下来使用集合中的数据 END;
nohandsome 2013-07-12
  • 打赏
  • 举报
回复
你以前是SQL SERVER ORACLE select 必须和INTO 一起使用 但select的结果没有或者为多条都会报错,如果返回多行,可以用游标获取结果,或者用集合元素存值
qq3895 2013-07-12
  • 打赏
  • 举报
回复
bulk collect 能返回多列吗? 我查出的结果是多行多列的
aoxianglin 2013-07-12
  • 打赏
  • 举报
回复
这个查询返回是多行的记录 bulk collect
qq3895 2013-07-12
  • 打赏
  • 举报
回复
declare cursor cr1 is select Avgsalary from (select E.grade, E.TestLevel, (select AA * 2 BB from (select avg(Salarys) AA from andy_shen_salary_information S)) Avgsalary from andy_shen_emp_infomation E where E.GRADE >= 5 and E.Grade <= 7 and E.TestLevel > 4); i cr1%rowtype; result1 number; result2 number; result3 number; result4 number; begin for i in cr1 loop --dbms_output.put_line(i.Avgsalary); select NewCell,Salarys,SalaryMonth,Id into result1,result2,result3,result4 from(select (decode(AA,' ',i.Avgsalary)) NewCell,Salarys,salarymonth,Id from (select A.*, ' ' AA from andy_shen_salary_information A where Id in (select empid from andy_shen_emp_infomation E where E.GRADE >= 5 and E.Grade <= 7 and E.Testlevel > 4) and A.SALARYMONTH=6) where AA =' '); end loop; end; 现在加上into,他报ora-01422:exact fetch returns more than requested number of rows ora-06512:at line 28 求解!!!!!!!!
qq3895 2013-07-12
  • 打赏
  • 举报
回复
那再次基础上怎么叫select into
u010412956 2013-07-12
  • 打赏
  • 举报
回复
单独的select语句需要跟into配合。。基本常识了

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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