vortex.sql
Class vortexCallableStatement

java.lang.Object
  |
  +--vortex.sql.vortexStatement
        |
        +--vortex.sql.vortexPreparedStatement
              |
              +--vortex.sql.vortexCallableStatement

public class vortexCallableStatement
extends vortexPreparedStatement
implements java.sql.CallableStatement

CallableStatement is used to execute SQL stored procedures.

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 [,, ...]}
{call [,, ...]}

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.

See Also:
Connection.prepareCall(java.lang.String), ResultSet

Fields inherited from class vortex.sql.vortexPreparedStatement
npa
 
Fields inherited from class vortex.sql.vortexStatement
cName, conn, lcur, ldb, record, result
 
Constructor Summary
vortexCallableStatement(java.sql.Connection c, dbChannel db, java.lang.String sql)
           
 
Method Summary
 int executeUpdate()
          Execute a stored procedure.
 java.math.BigDecimal getBigDecimal(int col, int scale)
          Get the value of a NUMERIC parameter as a java.sql.Numeric object.
 boolean getBoolean(int col)
          Get the value of a BIT parameter as a Java boolean.
 byte getByte(int col)
          Get the value of a TINYINT parameter as a Java byte.
 byte[] getBytes(int col)
          Get the value of a SQL BINARY or VARBINARY parameter as a Java byte[]
 java.sql.Date getDate(int col)
          Get the value of a SQL DATE parameter as a java.sql.Date object
 double getDouble(int col)
          Get the value of a DOUBLE parameter as a Java double.
 float getFloat(int col)
          Get the value of a FLOAT parameter as a Java float.
 int getInt(int col)
          Get the value of a INTEGER parameter as a Java int.
 long getLong(int col)
          Get the value of a BIGINT parameter as a Java long.
 java.lang.Object getObject(int i)
          Get the value of a parameter as a Java object.
 short getShort(int col)
          Get the value of a SMALLINT parameter as a Java short.
 java.lang.String getString(int col)
          Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a Java String.
 java.sql.Time getTime(int col)
          Get the value of a SQL TIME parameter as a java.sql.Time object.
 java.sql.Timestamp getTimestamp(int col)
          Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
 void registerOutParameter(int col, int sqlType)
          Before executing a stored procedure call you must explicitly call registerOutParameter to register the java.sql.Type of each out parameter.
 void registerOutParameter(int col, int sqlType, int scale)
          Use this version of registerOutParameter for registering Numeric or Decimal out parameters.
 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 vortex.sql.vortexPreparedStatement
clearParameters, execute, executeQuery, setAsciiStream, setBigDecimal, setBinaryStream, setBoolean, setByte, setBytes, setDate, setDouble, setFloat, setInt, setLong, setNull, setObject, setObject, setObject, setShort, setString, setTime, setTimestamp, setUnicodeStream
 
Methods inherited from class vortex.sql.vortexStatement
cancel, clearWarnings, close, execute, executeQuery, executeUpdate, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

vortexCallableStatement

public vortexCallableStatement(java.sql.Connection c,
                               dbChannel db,
                               java.lang.String sql)
                        throws java.sql.SQLException
Method Detail

registerOutParameter

public void registerOutParameter(int col,
                                 int sqlType)
                          throws java.sql.SQLException
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.

Specified by:
registerOutParameter in interface java.sql.CallableStatement
Parameters:
column - 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:
java.sql.SQLException - thrown if column out of range
See Also:
java.sql.Types

registerOutParameter

public void registerOutParameter(int col,
                                 int sqlType,
                                 int scale)
                          throws java.sql.SQLException
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.

Specified by:
registerOutParameter in interface java.sql.CallableStatement
Parameters:
column - 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:
java.sql.SQLException - thrown if column out of range
See Also:
java.sql.Types

wasNull

public boolean wasNull()
                throws java.sql.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 find if the value was SQL NULL.

Specified by:
wasNull in interface java.sql.CallableStatement
Returns:
true if the last parameter read was SQL NULL
Throws:
java.sql.SQLException - Not apply

getString

public java.lang.String getString(int col)
                           throws java.sql.SQLException
Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a Java String.
Specified by:
getString in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getBoolean

public boolean getBoolean(int col)
                   throws java.sql.SQLException
Get the value of a BIT parameter as a Java boolean.
Specified by:
getBoolean in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is false
Throws:
java.sql.SQLException - thrown if column out of range

getByte

public byte getByte(int col)
             throws java.sql.SQLException
Get the value of a TINYINT parameter as a Java byte.
Specified by:
getByte in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getShort

public short getShort(int col)
               throws java.sql.SQLException
Get the value of a SMALLINT parameter as a Java short.
Specified by:
getShort in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getInt

public int getInt(int col)
           throws java.sql.SQLException
Get the value of a INTEGER parameter as a Java int.
Specified by:
getInt in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getLong

public long getLong(int col)
             throws java.sql.SQLException
Get the value of a BIGINT parameter as a Java long.
Specified by:
getLong in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getFloat

public float getFloat(int col)
               throws java.sql.SQLException
Get the value of a FLOAT parameter as a Java float.
Specified by:
getFloat in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getDouble

public double getDouble(int col)
                 throws java.sql.SQLException
Get the value of a DOUBLE parameter as a Java double.
Specified by:
getDouble in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is 0
Throws:
java.sql.SQLException - thrown if column out of range

getBigDecimal

public java.math.BigDecimal getBigDecimal(int col,
                                          int scale)
                                   throws java.sql.SQLException
Get the value of a NUMERIC parameter as a java.sql.Numeric object.
Specified by:
getBigDecimal in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getBytes

public byte[] getBytes(int col)
                throws java.sql.SQLException
Get the value of a SQL BINARY or VARBINARY parameter as a Java byte[]
Specified by:
getBytes in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getDate

public java.sql.Date getDate(int col)
                      throws java.sql.SQLException
Get the value of a SQL DATE parameter as a java.sql.Date object
Specified by:
getDate in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getTime

public java.sql.Time getTime(int col)
                      throws java.sql.SQLException
Get the value of a SQL TIME parameter as a java.sql.Time object.
Specified by:
getTime in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getTimestamp

public java.sql.Timestamp getTimestamp(int col)
                                throws java.sql.SQLException
Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
Specified by:
getTimestamp in interface java.sql.CallableStatement
Parameters:
column - the first parameter is 1, the second is 2, ...
Returns:
the parameter value; if the value is SQL NULL the result is null
Throws:
java.sql.SQLException - thrown if column out of range

getObject

public java.lang.Object getObject(int i)
                           throws java.sql.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, by specifying a targetSqlType of java.sql.types.OTHER which allows the driver to return a database specific Java type.

Specified by:
getObject in interface java.sql.CallableStatement
Parameters:
i - The first parameter is 1, the second is 2, ...
Returns:
A java.lang.Object holding the OUT parameter value.
Throws:
java.sql.SQLException - thrown if column out of range
See Also:
java.sql.Types

executeUpdate

public int executeUpdate()
                  throws java.sql.SQLException
Execute a stored procedure.
Returns:
either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - thrown if DB actions fail.
Overrides:
executeUpdate in class vortexPreparedStatement