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的错误 
求解!!!!OracleCursorselect

解决方案 »

  1.   

    单独的select语句需要跟into配合。。基本常识了
      

  2.   

    那再次基础上怎么叫select into
      

  3.   

    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求解!!!!!!!!
      

  4.   

    这个查询返回是多行的记录
    bulk collect
      

  5.   

    bulk collect 能返回多列吗?我查出的结果是多行多列的
      

  6.   

    你以前是SQL SERVER ORACLE select 必须和INTO 一起使用 但select的结果没有或者为多条都会报错,如果返回多行,可以用游标获取结果,或者用集合元素存值
      

  7.   

     在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;
      

  8.   

    他也只能返回多行单列,现在主要是多行多列,貌似bulk collect 行不通吧