1.50.39

interbase.interclient
Class CallableStatement

java.lang.Object
  |
  +--interbase.interclient.Statement
        |
        +--interbase.interclient.PreparedStatement
              |
              +--interbase.interclient.CallableStatement

public final class CallableStatement
extends PreparedStatement
implements CallableStatement

Represents an SQL stored procedure.

JDBC provides a stored procedure SQL escape that allows stored procedures to be called in a standard way for all RDBMS's. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters may be used for input, output or both. Parameters are refered to sequentially, by number. The first parameter is 1.

{?= call procedure-name [(arg1, arg2, ...)]}
{call procedure-name [(arg1, arg2, ...)]}

IN parameter values are set using the set methods inherited from PreparedStatement. The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here.

A Callable statement may return a ResultSet or multiple ResultSets. Multiple ResultSets are handled using operations inherited from Statement.

For maximum portability, a call's ResultSets and update counts should be processed prior to getting the values of output parameters.

A call's ResultSets and update counts should be processed prior to getting the values of output parameters.

InterClient notes:

InterBase does not distinguish between stored procedures which return result sets and those which return "out" parameters. InterBase embedded SQL (supported by the preprocessor gpre) allows for a syntax in which the singleton result set columns from a procedure call may be interpreted as out parameters if the procedure is called using "execute procedure PROC_CALL" rather than "select * from PROC_CALL". But the procedure definition itself is not distinguished as either a "select procedure" or an "executable procedure", it is up to the caller to choose.

Because of this dual semantics for a procedure call, we had to choose which behavior to bestow on the escape syntax {call PROC_CALL (...)}. In order to support InterBase procedures in their generality and to conform to JDBC standards, InterBase stored procedures return all outputs in a result set, never as OUT parameters. So effectively, a CallableStatement is executed in the same way as a PreparedStatement for InterBase.

The following example demonstrates how to prepare and execute an InterBase stored procedure call which returns multiple rows.

 CallableStatement cs = c.prepareCall ("select * from PROC_CALL (?, ...)");
 ResultSet rs = cs.executeQuery ();
 
If a stored procedure call is known to return only a single row or no rows at all, then it should be prepared as follows
 CallableStatement cs = c.prepareCall ("execute procedure PROC_CALL (?, ...)");
 cs.execute ();  // may or may not spawn a singleton result set
 ResultSet rs = cs.getResultSet ();
 
Finally, the generalized escape syntax
 CallableStatement cs = c.prepareCall ("{call PROC_CALL (?, ...)}");
 cs.execute ();  // may or may not spawn a result set
 ResultSet rs = cs.getResultSet ();
 
is a standard notation which may be used for both kinds of procedures, that is, whether or not results are returned. If results are returned, they are returned as a result set.

In summary, InterBase does not support out parameters distinct from a result set. Although InterClient could interprete a singleton result set as out parameters as done by gpre, it is the intention of the SQL standard that result sets and out parameters be distinct entities, so that a stored procedure could return both a result set and out parameters independently.

Since:
JDBC 1, with extended behavior in JDBC 2
See Also:
Connection.prepareCall(java.lang.String), ResultSet

Method Summary
 Array getArray(int i)
          Get an Array OUT parameter.
 BigDecimal getBigDecimal(int parameterIndex)
          Get the value of a NUMERIC parameter as a java.math.BigDecimal object.
 BigDecimal getBigDecimal(int parameterIndex, int scale)
          Deprecated. to be deprecated in future release, replaced by getBigDecimal(int) without scale in JDBC 2
 Blob getBlob(int i)
          Get a BLOB OUT parameter.
 boolean getBoolean(int parameterIndex)
          Get the value of a BIT parameter as a Java boolean.
 byte getByte(int parameterIndex)
          Get the value of a TINYINT parameter as a Java byte.
 byte[] getBytes(int parameterIndex)
          Get the value of a SQL BINARY or VARBINARY parameter as a Java byte[].
 Clob getClob(int i)
          Get a CLOB OUT parameter.
 Date getDate(int parameterIndex)
          Get the value of a SQL DATE parameter as a java.sql.Date object.
 Date getDate(int parameterIndex, Calendar cal)
          Get the value of an SQL DATE parameter as a java.sql.Date object InterClient note: Throws a DriverNotCapableException.
 double getDouble(int parameterIndex)
          Get the value of a DOUBLE parameter as a Java double.
 float getFloat(int parameterIndex)
          Get the value of a FLOAT parameter as a Java float.
 int getInt(int parameterIndex)
          Get the value of an INTEGER parameter as a Java int.
 long getLong(int parameterIndex)
          Get the value of a BIGINT parameter as a Java long.
 Object getObject(int parameterIndex)
          Get the value of a parameter as a Java object.
 Object getObject(int i, Map map)
          Returns an object representing the value of OUT parameter i.
 Ref getRef(int i)
          Get a REF(<structured-type>) OUT parameter.
 short getShort(int parameterIndex)
          Get the value of a SMALLINT parameter as a Java short.
 String getString(int parameterIndex)
          Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a Java String.
 Time getTime(int parameterIndex)
          Get the value of a SQL TIME parameter as a java.sql.Time object.
 Time getTime(int parameterIndex, Calendar cal)
          Get the value of an SQL TIME parameter as a java.sql.Time object.
 Timestamp getTimestamp(int parameterIndex)
          Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
 Timestamp getTimestamp(int parameterIndex, Calendar cal)
          Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
 void registerOutParameter(int parameterIndex, int sqlType)
          Register an out parameter to a stored procedure.
 void registerOutParameter(int parameterIndex, int sqlType, int scale)
          Register a Numeric or Decimal out parameter to a stored procedure.
 boolean wasNull()
          An OUT parameter may have the value of SQL NULL; wasNull reports whether the last value read has this special value.
 
Methods inherited from class interbase.interclient.PreparedStatement
addBatch, clearParameters, execute, executeQuery, executeUpdate, getMetaData, getParameterMetaData, getPlan, getResultSetMetaData, setArray, setAsciiStream, setBigDecimal, setBinaryStream, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNull, setObject, setObject, setObject, setRef, setShort, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream
 
Methods inherited from class interbase.interclient.Statement
addBatch, cancel, clearBatch, clearWarnings, close, execute, executeBatch, executeQuery, executeUpdate, finalize, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerOutParameter

public void registerOutParameter(int parameterIndex,
                                 int sqlType)
                          throws SQLException
Register an out parameter to a stored procedure.

Before executing a stored procedure call, you must explicitly call registerOutParameter to register the java.sql.Type of each out parameter.

Note: When reading the value of an out parameter, you must use the getXXX method whose Java type XXX corresponds to the parameter's registered SQL type.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
registerOutParameter in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2,...
sqlType - SQL type code defined by java.sql.Types; for parameters of type Numeric or Decimal use the version of registerOutParameter that accepts a scale value.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported
See Also:
java.sql.Types

registerOutParameter

public void registerOutParameter(int parameterIndex,
                                 int sqlType,
                                 int scale)
                          throws SQLException
Register a Numeric or Decimal out parameter to a stored procedure.

Use this version of registerOutParameter for registering Numeric or Decimal out parameters.

Note: When reading the value of an out parameter, you must use the getXXX method whose Java type XXX corresponds to the parameter's registered SQL type.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
registerOutParameter in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
sqlType - use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
scale - a value greater than or equal to zero representing the desired number of digits to the right of the decimal point.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported
See Also:
java.sql.Types

wasNull

public boolean wasNull()
                throws SQLException
An OUT parameter may have the value of SQL NULL; wasNull reports whether the last value read has this special value.

Note: You must first call getXXX on a parameter to read its value and then call wasNull() to see if the value was SQL NULL.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
wasNull in interface CallableStatement
Returns:
true if the last parameter read was SQL NULL
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getString

public String getString(int parameterIndex)
                 throws SQLException
Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a Java String.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getString in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getBoolean

public boolean getBoolean(int parameterIndex)
                   throws SQLException
Get the value of a BIT parameter as a Java boolean.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getBoolean in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is false.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getByte

public byte getByte(int parameterIndex)
             throws SQLException
Get the value of a TINYINT parameter as a Java byte.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getByte in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getShort

public short getShort(int parameterIndex)
               throws SQLException
Get the value of a SMALLINT parameter as a Java short.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getShort in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getInt

public int getInt(int parameterIndex)
           throws SQLException
Get the value of an INTEGER parameter as a Java int.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getInt in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getLong

public long getLong(int parameterIndex)
             throws SQLException
Get the value of a BIGINT parameter as a Java long.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getLong in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getFloat

public float getFloat(int parameterIndex)
               throws SQLException
Get the value of a FLOAT parameter as a Java float.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getFloat in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getDouble

public double getDouble(int parameterIndex)
                 throws SQLException
Get the value of a DOUBLE parameter as a Java double.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getDouble in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is 0.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getBigDecimal

public BigDecimal getBigDecimal(int parameterIndex,
                                int scale)
                         throws SQLException
Deprecated. to be deprecated in future release, replaced by getBigDecimal(int) without scale in JDBC 2
Get the value of a NUMERIC parameter as a java.math.BigDecimal object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getBigDecimal in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
scale - a value greater than or equal to zero representing the desired number of digits to the right of the decimal point.
Returns:
the parameter value; if the value is SQL NULL, the result is null.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getBytes

public byte[] getBytes(int parameterIndex)
                throws SQLException
Get the value of a SQL BINARY or VARBINARY parameter as a Java byte[].

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getBytes in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getDate

public Date getDate(int parameterIndex)
             throws SQLException
Get the value of a SQL DATE parameter as a java.sql.Date object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getDate in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getTime

public Time getTime(int parameterIndex)
             throws SQLException
Get the value of a SQL TIME parameter as a java.sql.Time object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getTime in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getTimestamp

public Timestamp getTimestamp(int parameterIndex)
                       throws SQLException
Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getTimestamp in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, not supported

getObject

public Object getObject(int parameterIndex)
                 throws SQLException
Get the value of a parameter as a Java object.

This method returns a Java object whose type coresponds to the SQL type that was registered for this parameter using registerOutParameter.

Note that this method may be used to read datatabase-specific, abstract data types. This is done by specifying a targetSqlType of java.sql.types.OTHER, which allows the driver to return a database-specific Java type.

JDBC 2 note: The behavior of method getObject() is extended to materialize data of SQL user-defined types. When the OUT parameter is a UDT value, the behavior of this method is as if it were a call to: getObject(parameterIndex, this.getConnection().getTypeMap())

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getObject in interface CallableStatement
Parameters:
parameterIndex - The first parameter is 1, the second is 2, ...
Returns:
A java.lang.Object holding the OUT parameter value.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 1, with extended behavior in JDBC 2, not supported
See Also:
java.sql.Types

getBigDecimal

public BigDecimal getBigDecimal(int parameterIndex)
                         throws SQLException
Get the value of a NUMERIC parameter as a java.math.BigDecimal object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getBigDecimal in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value (full precision); if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getObject

public Object getObject(int i,
                        Map map)
                 throws SQLException
Returns an object representing the value of OUT parameter i. Use the map to determine the class from which to construct data of SQL structured and distinct types.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getObject in interface CallableStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
map - the mapping from SQL type names to Java classes
Returns:
a java.lang.Object holding the OUT parameter value.
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getRef

public Ref getRef(int i)
           throws SQLException
Get a REF(<structured-type>) OUT parameter.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getRef in interface CallableStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
Returns:
an object representing data of an SQL REF Type
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getBlob

public Blob getBlob(int i)
             throws SQLException
Get a BLOB OUT parameter.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getBlob in interface CallableStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
Returns:
an object representing a BLOB
Throws:
SQLException - if a database-access error occurs.
Since:
JDBC 2, not supported

getClob

public Clob getClob(int i)
             throws SQLException
Get a CLOB OUT parameter.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getClob in interface CallableStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
Returns:
an object representing a CLOB
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getArray

public Array getArray(int i)
               throws SQLException
Get an Array OUT parameter.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getArray in interface CallableStatement
Parameters:
i - the first parameter is 1, the second is 2, ...
Returns:
an object representing an SQL array
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getDate

public Date getDate(int parameterIndex,
                    Calendar cal)
             throws SQLException
Get the value of an SQL DATE parameter as a java.sql.Date object

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getDate in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getTime

public Time getTime(int parameterIndex,
                    Calendar cal)
             throws SQLException
Get the value of an SQL TIME parameter as a java.sql.Time object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getTime in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

getTimestamp

public Timestamp getTimestamp(int parameterIndex,
                              Calendar cal)
                       throws SQLException
Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.

InterClient note: Throws a DriverNotCapableException. InterBase does not support out parameters distinct from a result set.

Specified by:
getTimestamp in interface CallableStatement
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database access error occurs.
Since:
JDBC 2, not supported

1.50.39

Send comments or suggestions to icsupport@interbase.com