Oracle 5.0 Reference Manual page 2111

Table of Contents

Advertisement

// parameters using either method, as well
// as retrieve output parameters using either
// method, regardless of what method was
// used to register them.
//
// The following examples show how to use
// the various methods of registering
// output parameters (you should of course
// use only one registration per parameter).
//
//
// Registers the second parameter as output, and
// uses the type 'INTEGER' for values returned from
// getObject()
//
cStmt.registerOutParameter(2, Types.INTEGER);
//
// Registers the named parameter 'inOutParam', and
// uses the type 'INTEGER' for values returned from
// getObject()
//
cStmt.registerOutParameter("inOutParam", Types.INTEGER);
...
3. Set the input parameters (if any exist)
Input and in/out parameters are set as for
CallableStatement
Example 20.6. Connector/J: Setting
...
//
// Set a parameter by index
//
cStmt.setString(1, "abcdefg");
//
// Alternatively, set a parameter using
// the parameter name
//
cStmt.setString("inputParameter", "abcdefg");
//
// Set the 'in/out' parameter using an index
//
cStmt.setInt(2, 1);
//
// Alternatively, set the 'in/out' parameter
// by name
//
cStmt.setInt("inOutParam", 1);
...
4. Execute the CallableStatement, and retrieve any result sets or output parameters.
Although
CallableStatement
(executeUpdate(),
execute(), as you do not need to know ahead of time if the stored procedure returns result sets:
JDBC Concepts
PreparedStatement
also supports setting parameters by name:
CallableStatement
supports calling any of the
or execute()), the most flexible method to call is
executeQuery()
2091
objects. However,
input parameters
execute methods
Statement

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents