Aug 20, 2019

Call PL/SQL Procedure | From OAF Page



 import oracle.jdbc.OracleCallableStatement;  
 import oracle.jdbc.OracleTypes;
 import oracle.jbo.domain.Number;
 import oracle.jbo.domain.Date;
   
 public void callPLSQLProc(Number id,String code,Date currentDate)  
 {  
      OracleCallableStatement callableStatement = null;  
      try  
      {  
           String callProc = " BEGIN xxx_pkg.xxx_proc "+  
                                         "(p_id             => :1," +  
                                         " p_code           => :2," +
                                         " p_date           => :3," +
                                         " p_commit         => :4," +                                                  
                                         " x_return_status  => :5," +  
                                         " x_msg_data       => :6," +  
                                         " x_msg_count      => :7);"+  
                                    " END; ";  
           callableStatement = (OracleCallableStatement)getOADBTransaction().createCallableStatement(callProc,1);  
           callableStatement.setNUMBER(1, id);  
           callableStatement.setString(2, code);          
           callableStatement.setDATE(3, currentDate);    
           callableStatement.setString(4, "Y");     
           callableStatement.registerOutParameter(5,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(6,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(7,OracleTypes.NUMBER,255);    
           callableStatement.execute();  
           String resultMessage = (String)callableStatement.getString(5);  
           String msgData  = (String)callableStatement.getString(6);  
      }  
      catch(Exception e)  
      {  
           e.printStackTrace();  
           throw new OAException(e.toString(),OAException.ERROR);  
      }  
      finally  
      {  
           try  
           {  
                callableStatement.close();  
           }  
           catch(Exception exception2)  
           {  
                throw OAException.wrapperException(exception2);  
           }  
      }  
 }        

:1,:2,:3 & :4 è IN Parameter   
:5,:6,:7 è Out Parameter

No comments:

Post a Comment

Useful Workflow Commands

  WFLOAD apps/columbus789 0 Y DOWNLOAD APEXP_FINDEV.wft APEXP Locations: $PO_TOP/patch/115/import/US/porpocha.wft $PO_TOP/patch/115/import/U...