Thursday, September 13, 2012

Prepared Statment in OAF


 OADBTransactionImpl OADBTxn =
                                (OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction();
                try {
                    Connection conn =
                        pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
                    String Query =
                        "select nvl((SELECT approval_status from apps.XX_SAMPLE_TABLE" +
                        " where objective_id=:1),'Approved') status from dual";
                    PreparedStatement stmt = conn.prepareStatement(Query);
                    stmt.setInt(1, objectiveId);
                    for (ResultSet resultset = stmt.executeQuery();
                         resultset.next(); ) {
                        pageContext.writeDiagnostics(this, "Query Executed",
                                                     1);
                        String result = resultset.getString("status");//Get the result of the query and store in the string result
                    }
                } catch (Exception exception) {
                    throw new OAException("Error in Staffing Query" +
                                          exception, OAException.ERROR);
                }

No comments:

Post a Comment