日期:2014-05-17 浏览次数:21181 次
create or replace procedure get_user_name( v_UserCode in char, v_UserName out char) is begin select DECODE (tu.username, 'NULL', '没有找到该读者', tu.username) into v_UserName from T_user tu where tu.usercode = v_UserCode; end get_user_name;
------解决方案--------------------
CREATE OR REPLACE PROCEDURE test
(in_code IN VARCHAR2,
out_code out varchar2
)
IS
BEGIN
select name into
out_code
from t_user
where code=in_code ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
out_code:='没有找该读者';
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END test;
/
------解决方案--------------------
out 参数要事先定义个变量的再传进去的
其实你这用自定义函数就行了
CREATE OR REPLACE FUNCTIONtest 
(in_code  VARCHAR2, 
) 
RETURN varchar2
IS 
out_code  varchar2(100) ;
BEGIN 
    
   select name into  
          out_code 
       from t_user 
       where code=in_code  ;  
    
    return out_code;
   EXCEPTION 
     WHEN NO_DATA_FOUND THEN 
       return '没有找该读者'; 
     WHEN OTHERS THEN 
       -- Consider logging the error and then re-raise 
       RAISE; 
END test;