How to call stored PLSQL function or procedure in OAF controller

Jak wywołać procedurę albo funkcję z bazy z poziomu kontrolera OAF

package xx.oracle.apps.ar.creditmgt.application.webui;
 
import oracle.apps.ar.creditmgt.application.webui.creditApplicationCO;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
import oracle.apps.fnd.framework.server.OADBTransaction;
 
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.sql.Types;
 
public class xxcreditApplicationCO extends creditApplicationCO 
{
 
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
        {        
 
  			String s = (String)oapagecontext.getParameter("_FORM_SUBMIT_BUTTON"); 
 
        OAMessageLovInputBean CurrencyHandle = (OAMessageLovInputBean)oawebbean.findChildRecursive("Arcmcurrency");				
 
             if (s.equals("ArCmSubmit") && CurrencyHandle.getValue(oapagecontext) !=null)   // form submit
             {
                String Currency = CurrencyHandle.getValue(oapagecontext).toString();
 
                OAViewObject xoaviewobject = (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject("creditRequestsVO");
                oracle.jbo.Row row = xoaviewobject.first();
                String SiteUseId = row.getAttribute("SiteUseId").toString();
 
                String outParamValue; 
                OADBTransaction txn  = oapagecontext.getApplicationModule(oawebbean).getOADBTransaction();
                CallableStatement cs = txn.createCallableStatement("begin :1 := xx_ar_cmgt_util.VALIDATECURRENCY(:2,:3); end;",1);
 
                  try
                  {
                    cs.registerOutParameter(1, Types.VARCHAR);
                    cs.setString(2,SiteUseId);
                    cs.setString(3,Currency);
                    cs.execute();
                    outParamValue = cs.getString(1);
                    cs.close();
                  }
                  catch (SQLException sqle)
                  {
                      throw OAException.wrapperException(sqle);
                  }
 
                if (outParamValue.equals("N"))
                {
//                 throw new OAException(Currency+" is wrong currecy for this customer. Please choose other currency or setup customer for " +Currency+". "+SiteUseId+". "+outParamValue, OAException.INFORMATION);
 
                throw new OAException(Currency+" is wrong currecy for this customer. Please choose other currency or setup customer for " +Currency+". "+SiteUseId+". "+outParamValue, OAException.INFORMATION);
 
                }
 
         	 }
        super.processFormRequest(oapagecontext, oawebbean);
       }
}

 

 

 

 

 

Ten wpis został opublikowany w kategorii OAF i oznaczony tagami . Dodaj zakładkę do bezpośredniego odnośnika.

Dodaj komentarz