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());
}
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
Post a Comment