Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

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 2: Line 2:
 
== How to handle nonJDBC arguments for Oracle Stored Procedures ==
 
== How to handle nonJDBC arguments for Oracle Stored Procedures ==
  
The standard way of handling a Stored Procedure is to build an instance of <tt>oracle.toplink.queryframework.StoredProcedureCall</tt>. However, the arguments must be compatible with the JDBC specification.
+
The standard way of handling a Stored Procedure is to build an instance of <tt>org.eclipse.persistence.queries.StoredProcedureCall</tt>. 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: <tt>oracle.toplink.platform.database.oracle.PLSQLStoredProcedureCall</tt>:
+
To handle nonJDBC arguments (e.g. BOOLEAN, PLS_INTEGER, PL/SQL record, etc.) a new sub-class has been created: <tt>org.eclipse.persistence.platform.database.oracle.PLSQLStoredProcedureCall</tt>:
  
 
For the target procedure:
 
For the target procedure:
 
  <font color="#000000">'''<font color="#575757">procedure</font>''' bool_test<font color="#555555">(</font>x '''<font color="#575757">IN</font>''' '''<font color="#575757">BOOLEAN</font>'''<font color="#555555">)</font></font>
 
  <font color="#000000">'''<font color="#575757">procedure</font>''' bool_test<font color="#555555">(</font>x '''<font color="#575757">IN</font>''' '''<font color="#575757">BOOLEAN</font>'''<font color="#555555">)</font></font>
  
the TopLink code would be:
+
the EclipseLink code would be:
<font color="#000000">'''<font color="#7f0055">import</font>'''<font color="#7f0055"> oracle</font><font color="#7f0055">.</font><font color="#7f0055">toplink</font><font color="#7f0055">.</font><font color="#7f0055">internal</font><font color="#7f0055">.</font><font color="#7f0055">helper</font><font color="#7f0055">.</font><font color="#7f0055">NonSynchronizedVector</font><font color="#7f0055"><nowiki>;</nowiki></font>
+
'''<font color="#7f0055">import</font>'''<font color="#7f0055"> oracle</font><font color="#7f0055">.</font><font color="#7f0055">toplink</font><font color="#7f0055">.</font><font color="#7f0055">platform</font><font color="#7f0055">.</font><font color="#7f0055">database</font><font color="#7f0055">.</font><font color="#7f0055">oracle</font><font color="#7f0055">.</font><font color="#7f0055">PLSQLStoredProcedureCall</font><font color="#7f0055"><nowiki>;</nowiki></font>
+
'''<font color="#7f0055">import</font>'''<font color="#7f0055"> static oracle</font><font color="#7f0055">.</font><font color="#7f0055">toplink</font><font color="#7f0055">.</font><font color="#7f0055">platform</font><font color="#7f0055">.</font><font color="#7f0055">database</font><font color="#7f0055">.</font><font color="#7f0055">oracle</font><font color="#7f0055">.</font><font color="#7f0055">OraclePLSQLTypes</font><font color="#7f0055">.</font><font color="#7f0055">PLSQLBoolean</font><font color="#7f0055"><nowiki>;</nowiki></font>
+
+
'''<font color="#7f0055">public</font>''' '''<font color="#7f0055">class</font>''' NonJDBCTestSuite {
+
+
  '''<font color="#7f0055">public</font>''' '''<font color="#7f0055">static</font>''' '''<font color="#7f0055">void</font>''' main('''<font color="#7f0055">String</font>''' args[]) {
+
    PLSQLStoredProcedureCall call = '''<font color="#7f0055">new</font>''' PLSQLStoredProcedureCall();
+
    call.setProcedureName(<font color="#2a00ff">"bool_in_test"</font>);
+
    call.addNamedArgument(<font color="#2a00ff">"X"</font>, PLSQLBoolean);
+
    DataModifyQuery query = '''<font color="#7f0055">new</font>''' DataModifyQuery();
+
    query.addArgument(<font color="#2a00ff">"X"</font>);
+
    query.setCall(call);
+
    '''<font color="#7f0055">Vector</font>''' queryArgs = '''<font color="#7f0055">new</font>''' NonSynchronizedVector();
+
    queryArgs.add('''<font color="#7f0055">Integer</font>'''.valueOf(1));
+
    s.executeQuery(query, queryArgs);
+
  }
+
}
+
</font>
+

Revision as of 13:58, 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 org.eclipse.persistence.queries.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: org.eclipse.persistence.platform.database.oracle.PLSQLStoredProcedureCall:

For the target procedure:

procedure bool_test(x IN BOOLEAN)

the EclipseLink code would be:

Back to the top