Skip to content

Instantly share code, notes, and snippets.

@jonbartlett
Created August 25, 2009 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbartlett/175145 to your computer and use it in GitHub Desktop.
Save jonbartlett/175145 to your computer and use it in GitHub Desktop.
Call PL/SQL from Java /OAF
import oracle.jdbc.OracleCallableStatement;
import oracle.sql.NUMBER;
import java.sql.*;
import java.sql.Connection;
OracleCallableStatement stmt = null;
try {
OADBTransaction trx = oaapplicationmodule.getOADBTransaction();
String sqlStmt = "begin vpc_icms_cash_flow.p_create_new_version(?,?); end;";
Connection connection = oaapplicationmodule.getOADBTransaction().getJdbcConnection();
stmt = (OracleCallableStatement) connection.prepareCall(sqlStmt);
stmt.setNUMBER(1, new NUMBER(contractId, 0)); // Bind 1st parameter
stmt.setNUMBER(2, new NUMBER(contractVerNum, 0)); // Bind 2nd parameter
stmt.execute();
} catch (SQLException e) {
if (flag) {
oapagecontext.writeDiagnostics(this, "VPC: Exception:" + e, 1);
}
} finally {
try {
if (stmt != null) {
stmt.close(); // close the statement
}
} catch (SQLException ex) {
if (flag) {
oapagecontext.writeDiagnostics(this, "VPC: Exception2:" + ex, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment