Oracle 返回结果集的 存储过程

create or replace
PROCEDURE SPGETROLELIST 
(
  P_APPCODE IN VARCHAR2  
, P_USERROLE IN VARCHAR2  
, CUR_RESULT OUT SYS_REFCURSOR  
) AS 

P_ApproveFlag char(1);  

BEGIN

    If P_USERROLE = 'M'  Then
        begin
        P_ApproveFlag := 'R';  
        end;
    Else  
        begin
        P_ApproveFlag := '';  
        end;
    End If; 

    open CUR_RESULT for 
    Select * 
    From  Role  
    Where AppCode = P_APPCODE  
    And   (ApproveStatus = 'P' or ApproveStatus = P_ApproveFlag)  
    And   (Status <> 'A' Or (Status = 'A' And ApproveStatus Is Not Null));  

    exception
    when no_data_found then
        open CUR_RESULT for
        select null
        from Role
        where 1 =2 ;
 
 
END SPGETROLELIST;

 

你可能感兴趣的:(oracle)