2016-01-29 102 views
-1

如何解決這一個,無法取得? 我傳遞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' 

回答

0

你的表可能有多於1行的名稱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; 
+0

是它返回2行,三江源 – S123DB8

+0

如果你的作品,然後通過點擊打勾符號上留下答案的接受答案,因此它可以被關閉。謝謝 – Utsav