To Call a Procedure :
OADBTransactionImpl txn =
(OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction();
CallableStatement cs =
txn.createCallableStatement("begin :1 := check_Approval_Status(:2,:3); end;",
OADBTransaction.DEFAULT);
try {
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(1, "retStatus");
cs.setInt(2, scoreCardId);
cs.setInt(3, personId);
String outParamValue = null;
cs.execute();
outParamValue = cs.getString(1);
cs.close();
if (outParamValue.equals("N")) {
OASubmitButtonBean oas =
(OASubmitButtonBean)webBean.findChildRecursive("MgrTransfer");
oas.setDisabled(true);
}
} catch (SQLException sqle) {
throw new OAException("Error in Staffing Query",
OAException.ERROR);
}
Example 2 :
OADBTransactionImpl OADBTxn =
(OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction();
String query_String = new String();
query_String =
"BEGIN insert_into_table(:1,:2,:3,:4,:5);END;";
OracleCallableStatement stmt =
(OracleCallableStatement)OADBTxn.createCallableStatement(query_String,
-1);
try {
stmt.setInt(1, jObjectiveId);
stmt.setString(2, jName);
stmt.setInt(3, jScorecardId);
stmt.setString(4, jGroupCode);
stmt.setInt(5, jOwningPersonId);
stmt.execute();
stmt.close();
} catch (SQLException e) {
throw new OAException("Error in Staffing Query : " +
e, OAException.ERROR);
}
To call a Function
OADBTransactionImpl txn = (OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction();
CallableStatement cs =
txn.createCallableStatement("begin :1 := xx_pra_func(:2); end;",OADBTransaction.DEFAULT);
try {
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(1, "ValuesI");
cs.setInt(2, 100);
String outParamValue = null;
cs.execute();
outParamValue = cs.getString(1);
cs.close();
throw new OAException("Function us "+outParamValue);
} catch (SQLException sqle) {
throw new OAException("Error in Staffing Query", OAException.ERROR);
}
No comments:
Post a Comment