传递参数但无法获取?

时间:2016-01-29 04:02:52

标签: oracle plsql oracle-sqldeveloper

如何解决这个问题,无法获取?   我传递IN参数但仍无法获取。

 create or replace procedure p1(p_ename in varchar2,p_sal out number)is
 begin
  select salary into p_sal from employees where last_name=p_ename;
 dbms_output.put_line(p_sal);
 end;

 variable b number;
 execute p1('King',:b);


[info](https://infoallsite.wordpress.com/2016/01/29/unable-to-fetch- data)


 [error][1]

 ' got error ,but only one row has last_name as King, '
  how to resolve I  want  to get the salary of king.
  [1]: http://i.stack.imgur.com/AsOHG.png'

1 个答案:

答案 0 :(得分:0)

您的表名称King可能包含多行。

运行此

select count(*) from employees where last_name='King';

如果返回的行数超过1行,则必须选择需要选择的行。如果您想随机添加任何行,请在您的过程中使用此选择。

select salary into p_sal from employees 
where last_name=p_ename 
and rownum<2;