Calling plsql from controller

Use the following code as sample provinding the proper input parameter value along with the parameter type.


String sqlStatement =
"BEGIN " + "\n"
+" PACKAGE_NAME.update_item_details " + "\n"
+" (p_param1 => :1" + "\n"
+" ,p_param2 => :2" + "\n"
+" ,p_param3 => :3" + "\n"
+" );" + "\n"
+"END; " + "\n";

OracleCallableStatement cStmt = (OracleCallableStatement)this.tx.createCallableStatement(sqlStatement,1);
try
{
cStmt.setString(1,param1);
cStmt.setString(2,param2);
cStmt.setLong(3,param3);

cStmt.registerOutParameter(3, OracleTypes.NUMERIC, 0, 10);
cStmt.execute();

entityGroupId = cStmt.getLong(3);
}
catch (Exception e)
{
throw OAException.wrapperException(e);
}
finally
{
try
{
cStmt.close();
}
catch (Exception e)
{
throw OAException.wrapperException(e);
}
}

Hiç yorum yok: