Please find below sample code to call PL/SQL procedure from OA Framework page.
In the below example first 4 parameters are IN parameters and the last 3 parameters are OUT parameters.This example code is a function defined in the ApplicationModule.
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 xxaj_pkg.xxaj_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);
}
}
}
Package Spec is as below:
create
or replace package
xxaj_pkg
as
procedure
xxaj_proc (p_id
in number
,p_code
in varchar2
,p_date
in date
,p_commit
in varchar2
,x_return_status
out varchar2
,x_msg_data
out varchar2
,x_msg_count
out number
);
end
xxaj_pkg;
Feel free to point out if anything is missing/wrong in this blog.