Calling Plsql package from OAF Page through Callable Statement

There is a common requirement in OAF to call PLSQL package from controller class, I'm sharing this code snippet which will help developers to build their logic.

 Classes to Import

import java.sql.CallableStatement;
import java.sql.Types; 


Write below code either in processRequest or processFormRequest method

 OAApplicationModule am = pageContext.getApplicationModule(webBean);
String sql = "BEGIN XX_ORA_PKG.TEST_PRC (:1,:2,:3,:4); END;"; 
CallableStatement cs =am.getOADBTransaction().createCallableStatement(sql,OADBTransaction.DEFAULT); 
try
 {
 cs.registerOutParameter(1, Types.VARCHAR);
 cs.registerOutParameter(2, Types.VARCHAR); 
cs.setString(3, SupplierName); 
cs.setString(4, SupplierCode); 
cs.execute(); 
String output = cs.getString(1); 
cs.close(); 

catch (Exception ex) 

throw new OAException("Exception: ", ex.toString()); 
}

Comments

Popular posts from this blog

Sample HZ API's script to Create Contacts and Contact Points in Oracle

REST integration built-in OIC to read Large files with size more than 10MB