Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/nonJDBCArgsToStoredProcedures"

(How to handle nonJDBC arguments for Oracle Stored Procedures)
(How to handle nonJDBC arguments for Oracle Stored Procedures)
Line 10: Line 10:
  
 
the TopLink code would be:
 
the TopLink code would be:
 
<pre style='color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>import</span><span style='color:#7f0055; '> oracle</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>toplink</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>internal</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>helper</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>NonSynchronizedVector</span><span style='color:#7f0055; '>;</span>
 
<span style='color:#7f0055; font-weight:bold; '>import</span><span style='color:#7f0055; '> oracle</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>toplink</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>platform</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>database</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>oracle</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>PLSQLStoredProcedureCall</span><span style='color:#7f0055; '>;</span>
 
<span style='color:#7f0055; font-weight:bold; '>import</span><span style='color:#7f0055; '> static oracle</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>toplink</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>platform</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>database</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>oracle</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>OraclePLSQLTypes</span><span style='color:#7f0055; '>.</span><span style='color:#7f0055; '>PLSQLBoolean</span><span style='color:#7f0055; '>;</span>
 
 
<span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>class</span> NonJDBCTestSuite {
 
 
  <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>static</span> <span style='color:#7f0055; font-weight:bold; '>void</span> main(<span style='color:#7f0055; font-weight:bold; '>String</span> args[]) {
 
    PLSQLStoredProcedureCall call = <span style='color:#7f0055; font-weight:bold; '>new</span> PLSQLStoredProcedureCall();
 
    call.setProcedureName(<span style='color:#2a00ff; '>"bool_in_test"</span>);
 
    call.addNamedArgument(<span style='color:#2a00ff; '>"X"</span>, PLSQLBoolean);
 
    DataModifyQuery query = <span style='color:#7f0055; font-weight:bold; '>new</span> DataModifyQuery();
 
    query.addArgument(<span style='color:#2a00ff; '>"X"</span>);
 
    query.setCall(call);
 
    <span style='color:#7f0055; font-weight:bold; '>Vector</span> queryArgs = <span style='color:#7f0055; font-weight:bold; '>new</span> NonSynchronizedVector();
 
    queryArgs.add(<span style='color:#7f0055; font-weight:bold; '>Integer</span>.valueOf(1));
 
    s.executeQuery(query, queryArgs);
 
  }
 
}
 
</pre>
 

Revision as of 13:09, 23 November 2007

{available as of EclipseLink 1.0M2}

How to handle nonJDBC arguments for Oracle Stored Procedures

The standard way of handling a Stored Procedure is to build an instance of oracle.toplink.queryframework.StoredProcedureCall. However, the arguments must be compatible with the JDBC specification.

To handle nonJDBC arguments (e.g. BOOLEAN, PLS_INTEGER, PL/SQL record, etc.) a new sub-class has been created: oracle.toplink.platform.database.oracle.PLSQLStoredProcedureCall:

For the target procedure:

procedure bool_test(x IN BOOLEAN)

the TopLink code would be: