现有一张表,表名为emp:
ID   NAME   SALARY
100  Jacky  5600
101  Rose   3000
102  John   4500接着创建了一个过程(在10g R2版SQL*Plus环境):
create or replace procedure emp_info(empid number) as
empname varchar2(20);
empsalary number(5);
begin
execute immediate 
'select name,salary from store.emp where id=:1' using empid returning into empname,empsalary;
dbms_output.put_line(empname||'salary is:::'||empsalary);
end emp_info;创建过程可以成功完成,但用call emp_info(101);调用时报错:
SQL> call emp_info(101);
call emp_info(101)
     *
第1行出现错误:
ORA-06547: INSERT, UPDATE 或 DELETE 语句必须使用 RETURNING 子句
ORA-06512: 在"SYS.EMP_INFO", line 5请问这是什么原因?该如何解决?

解决方案 »

  1.   

    补充一下:
    第6行的"'select name,salary from store.emp......"写错了,我用的是"'select name,salary from emp......"
      

  2.   

    create or replace procedure emp_info(empid number) as
    empname varchar2(20);
    empsalary number(5);
    begin
    execute immediate 
    'select name,salary from store.emp where id=:1'  into empname,empsalary using empid ;
    dbms_output.put_line(empname||'salary is:::'||empsalary);
    end emp_info;应该用 into 而不是 returning into 因为returning子句作用于insert,update,delete,上而select则不行!建议楼主发帖前先google下 你这个问题网上好多的。
      

  3.   

    To:skyspark(星)
     谢谢谢谢!这个问题困扰了我很久,我在网上也没少google或Baidu,却始终找不到解决问题的办法!你的回答让我拨云见日,茅塞顿开,只是本人囊中羞涩,已用完了积分,所以没法儿给你分了!不过还是要谢谢你!