DB2 for z/OS does not support dynamic execution of the CALL statement. For
calls to stored procedures that are on DB2 for z/OS data sources, the parameters
can be parameter markers or literals, but not expressions. The following types of
literals are supported:
v Integer
v Double
v Decimal
v Character
v Hexadecimal
v Graphic
For calls to stored procedures that are on IBM Informix Dynamic Server data
sources, the PreparedStatement object can be a CALL statement or an EXECUTE
PROCEDURE statement.
When you execute an SQL statement many times, you can get better performance
by creating the SQL statement as a PreparedStatement.
For example, the following UPDATE statement lets you update the employee table
for only one phone number and one employee number:
UPDATE EMPLOYEE SET PHONENO='4657' WHERE EMPNO='000010'
Suppose that you want to generalize the operation to update the employee table
for any set of phone numbers and employee numbers. You need to replace the
constant phone number and employee number with variables:
UPDATE EMPLOYEE SET PHONENO=? WHERE EMPNO=?
Variables of this form are called parameter markers. To execute an SQL statement
with parameter markers, you need to perform these steps:
1. Invoke the Connection.prepareStatement method to create a PreparedStatement
object.
2. Invoke the PreparedStatement.setXXX methods to pass values to the variables.
3. Invoke the PreparedStatement.executeUpdate method to update the table with
the variable values.
4. Invoke the PreparedStatement.close method to close the PreparedStatement
object when you have finished using that object.
The following code performs the previous steps to update the phone number to
’4657’ for the employee with employee number ’000010’. The numbers to the right
of selected statements correspond to the previously-described steps.
26 Application Programming Guide and Reference for Java
â„¢