Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Writing stored procedures : Using the OpenEdge SQL Java classes
 

Using the OpenEdge SQL Java classes

This section describes how you use the OpenEdge SQL Java classes to issue and process SQL statements in Java stored procedures.
To process SQL statements in a stored procedure, you must know whether the SQL statement generates output (in other words, if the statement is a query) or not. SELECT statements, for example, generate results: they retrieve data from one or more database tables and return the results as rows in a table.
Whether a statement generates such an SQL result set determines which OpenEdge SQL Java classes you should use to issue it. For example:
*To issue SQL statements that do not generate results (such as INSERT, GRANT, or CREATE), use the SQLIStatement class for one‑time execution, or the SQLPStatement class for repeated execution.
*To issue SQL statements that generate results (SELECT and, in some cases, CALL), use the SQLCursor class to retrieve rows from a database or another procedure's result set.
In either case, if you want to return a result set to the application, use the DhSQLResultSet class to store rows of data in a procedure result set. You must use DhSQLResultSet methods to transfer data from an SQL result set to the procedure result set for the calling application to process it. You can also use DhSQLResultSet methods to store rows of data generated internally by the procedure.
In addition, OpenEdge SQL provides the DhSQLException class so procedures can process and generate Java exceptions through the try, catch, and throw constructs.
* Passing values to SQL statements
* setParam method: pass input values to SQL statements
* getValue method: pass values from SQL result sets to variables
* Passing values to and from stored procedures: input and output parameters
* Implicit data type conversion between SQL and Java types
* Executing an SQL statement
* Immediate execution
* Prepared execution
* Retrieving data: the SQLCursor class
* Returning a procedure result set to applications: the RESULT clause and DhSQLResultSet
* Handling null values
* Setting SQL statement input parameters and procedure result set fields to null
* Assigning null values from SQL result sets: the SQLCursor.wasNULL method
* Handling errors
* Calling stored procedures from other stored procedures
* Stored procedure parameter requirements and usage
* INOUT and OUT parameters when one Java stored procedure calls another