oracle.jdbc
Interface OraclePreparedStatement

All Known Subinterfaces:
OracleCallableStatement

public abstract interface OraclePreparedStatement
extends java.sql.PreparedStatement, OracleStatement

Oracle prepared statement class.

Since:
8.1.7

Field Summary
static short FORM_CHAR
          Specifies the "Form Of Use" for CHAR, VARCHAR2 and CLOB datatypes.
static short FORM_NCHAR
          Specifies the "Form Of Use" for NCHAR, NVARCHAR2 and NCLOB datatypes.
 
Fields inherited from class oracle.jdbc.OracleStatement
EXPLICIT, IMPLICIT, NEW
 
Method Summary
 void defineParameterType(int param_index, int type, int max_size)
          Define the type under which you will bind the parameter and the maximum size of data you will bind in binds.
 int getExecuteBatch()
          Retrieve the batch value (for Oracle-style batching only).
 int sendBatch()
          Send any existing Oracle-style batch.
 void setARRAY(int paramIndex, ARRAY arr)
          Oracle specific.
 void setBfile(int paramIndex, BFILE file)
          Oracle specific.
 void setBFILE(int paramIndex, BFILE file)
          Oracle specific.
 void setBLOB(int paramIndex, BLOB lob)
          Oracle specific.
 void setCHAR(int paramIndex, CHAR ch)
          Oracle specific.
 void setCheckBindTypes(boolean flag)
          Enable/disable bind type checking.
 void setCLOB(int paramIndex, CLOB lob)
          Oracle specific.
 void setCursor(int paramIndex, java.sql.ResultSet rs)
          Oracle specific.
 void setCustomDatum(int paramIndex, CustomDatum x)
          Deprecated.  
 void setDATE(int paramIndex, DATE date)
          Oracle specific.
 void setDisableStmtCaching(boolean cache)
          Don't Cache this object even when the corresponding Connection is Cache Enabled.
 void setExecuteBatch(int batchValue)
          Set the batch value (for Oracle-style batching only).
 void setFixedCHAR(int paramIndex, java.lang.String x)
          Use this method when binding to a CHAR column in the where clause of a Select statement.
 void setFormOfUse(int paramIndex, short formOfUse)
          Set the "Form Of Use" of a column of the PreparedStatement.
 void setNUMBER(int paramIndex, NUMBER num)
          Oracle specific.
 void setOPAQUE(int paramIndex, OPAQUE val)
          Oracle specific.
 void setOracleObject(int paramIndex, Datum x)
          Oracle specific.
 void setORAData(int paramIndex, ORAData x)
          Oracle specific.
 void setPlsqlIndexTable(int paramIndex, java.lang.Object arrayData, int maxLen, int curLen, int elemSqlType, int elemMaxLen)
          Oracle OCI driver specific.
 void setRAW(int paramIndex, RAW raw)
          Oracle specific.
 void setREF(int paramIndex, REF ref)
          Oracle specific.
 void setRefType(int paramIndex, REF ref)
          Oracle specific.
 void setROWID(int paramIndex, ROWID rowid)
          Oracle specific.
 void setSTRUCT(int paramIndex, STRUCT struct)
          Oracle specific.
 void setStructDescriptor(int paramIndex, StructDescriptor desc)
          Oracle specific.
 void setTIMESTAMP(int paramIdx, TIMESTAMP x)
          Sets the designated parameter to an oracle.sql.TIMESTAMP value.
 void setTIMESTAMPLTZ(int paramIdx, TIMESTAMPLTZ x)
          Sets the designated parameter to an oracle.sql.TIMESTAMPLTZ value.
 void setTIMESTAMPTZ(int paramIdx, TIMESTAMPTZ x)
          Sets the designated parameter to an oracle.sql.TIMESTAMPTZ value.
 
Methods inherited from interface java.sql.PreparedStatement
addBatch, clearParameters, execute, executeQuery, executeUpdate, getMetaData, setArray, setAsciiStream, setBigDecimal, setBinaryStream, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNull, setNull, setObject, setObject, setObject, setRef, setShort, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream
 
Methods inherited from interface oracle.jdbc.OracleStatement
clearDefines, closeWithKey, creationState, defineColumnType, defineColumnType, defineColumnType, defineColumnTypeChars, getRowPrefetch, setResultSetCache, setRowPrefetch
 

Field Detail

FORM_NCHAR

public static final short FORM_NCHAR
Specifies the "Form Of Use" for NCHAR, NVARCHAR2 and NCLOB datatypes. It is used only in the argument to setFormOfUse().

FORM_CHAR

public static final short FORM_CHAR
Specifies the "Form Of Use" for CHAR, VARCHAR2 and CLOB datatypes. It is used only in the argument to setFormOfUse().
Method Detail

defineParameterType

public void defineParameterType(int param_index,
                                int type,
                                int max_size)
                         throws java.sql.SQLException
Define the type under which you will bind the parameter and the maximum size of data you will bind in binds.

Similarly to defineColumnType. Before executing a Query you may choose to inform JDBC of the type and maximum length of the bind parameter. If not, based on the setXXX call, the maximum length of the type is taken, i.e., for a setString a 4k buffer is allocated. This API does not reduce the network round trip. It is purely a memory optimization API.

Note: You should use Types.CHAR as the type value if you are going bind later as setCHAR and use Types.VARCHAR if you are going to bind as setString for effective results.

Parameters:
param_index - Index of bind parameter.
type - Type to be assigned to bind parameter. This type could be different from the native type of the column. Appropriate conversions will be done.
max_size - Maximum length of bind data in bytes.

getExecuteBatch

public int getExecuteBatch()
Retrieve the batch value (for Oracle-style batching only).
Returns:
the batch value last set by setExecuteBatch().

sendBatch

public int sendBatch()
              throws java.sql.SQLException
Send any existing Oracle-style batch.

This API is used in the context of Oracle-style batching. It flushes any batched executions before the batch value is reached. Executions normally happen when the number of executions reaches the batch value, which is set via the API setExecuteBatch(). It does not do anything if the statement does not use Oracle-style batching.

To use this API, the user must cast the PreparedStatement object to oracle.jdbc.driver.OraclePreparedStatement.

Returns:
the update count.
Throws:
java.sql.SQLException - if an error occurred.

setARRAY

public void setARRAY(int paramIndex,
                     ARRAY arr)
              throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.ARRAY.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBfile

public void setBfile(int paramIndex,
                     BFILE file)
              throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.BFILE value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBFILE

public void setBFILE(int paramIndex,
                     BFILE file)
              throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.BFILE value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBLOB

public void setBLOB(int paramIndex,
                    BLOB lob)
             throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.BLOB.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setCHAR

public void setCHAR(int paramIndex,
                    CHAR ch)
             throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.CHAR.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setCLOB

public void setCLOB(int paramIndex,
                    CLOB lob)
             throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.CLOB.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setCursor

public void setCursor(int paramIndex,
                      java.sql.ResultSet rs)
               throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a java.sql.ResultSet. This is used for RefCursor parameter only.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setCustomDatum

public void setCustomDatum(int paramIndex,
                           CustomDatum x)
                    throws java.sql.SQLException
Deprecated.  
Oracle specific. Sets the designated parameter to a oracle.sql.CustomDatum value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setORAData

public void setORAData(int paramIndex,
                       ORAData x)
                throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.ORAData value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setDATE

public void setDATE(int paramIndex,
                    DATE date)
             throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.DATE.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setExecuteBatch

public void setExecuteBatch(int batchValue)
                     throws java.sql.SQLException
Set the batch value (for Oracle-style batching only).

The Oracle Jdbc driver can "batch" multiple executions of a single statement with different bind variables. Actual execution happens when the number of batched executions reaches the "batch value", which is set by this API.

The batch value for this prepared statement can be set at any time via this API. Changing the batch value will affect all future executes.

The batch value will automatically be set to 1 by the driver if any of the bind types is of type stream. This overrides any value that the user might have set. Binds that were performed before any setXXXStream() is called, and that have not been executed, will be flushed (i.e. executed).

To use this API, the user must cast the PreparedStatement object to oracle.jdbc.driver.OraclePreparedStatement.

Parameters:
batchValue - batch value to be set. It must be greater than or equal to 1.

setFixedCHAR

public void setFixedCHAR(int paramIndex,
                         java.lang.String x)
                  throws java.sql.SQLException
Use this method when binding to a CHAR column in the where clause of a Select statement. A non padded comparision will be done unlike in setCHAR and setString case. Not particularly needed for an insert as the database will pad it.

Parameters:
paramIndex - index of the bind variable
x - the literal/variable to be bound.
Throws:
java.sql.SQLException - error while binding

setNUMBER

public void setNUMBER(int paramIndex,
                      NUMBER num)
               throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.NUMBER.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setOPAQUE

public void setOPAQUE(int paramIndex,
                      OPAQUE val)
               throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.OPAQUE.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setOracleObject

public void setOracleObject(int paramIndex,
                            Datum x)
                     throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.Datum value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setStructDescriptor

public void setStructDescriptor(int paramIndex,
                                StructDescriptor desc)
                         throws java.sql.SQLException
Oracle specific. Sets the bind type of designated parameter from an oracle.sql.StructDescriptor.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setRAW

public void setRAW(int paramIndex,
                   RAW raw)
            throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.RAW.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setREF

public void setREF(int paramIndex,
                   REF ref)
            throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.REF value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setRefType

public void setRefType(int paramIndex,
                       REF ref)
                throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.REF value.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setROWID

public void setROWID(int paramIndex,
                     ROWID rowid)
              throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.RAW.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setSTRUCT

public void setSTRUCT(int paramIndex,
                      STRUCT struct)
               throws java.sql.SQLException
Oracle specific. Sets the designated parameter to a oracle.sql.STRUCT.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setTIMESTAMP

public void setTIMESTAMP(int paramIdx,
                         TIMESTAMP x)
                  throws java.sql.SQLException
Sets the designated parameter to an oracle.sql.TIMESTAMP value.
Parameters:
paramIdx - specifies the parameter index. Index starts from 1.
x - specifies the parameter value.
Throws:
java.sql.SQLException - if an error occurred.
Since:
9i

setTIMESTAMPTZ

public void setTIMESTAMPTZ(int paramIdx,
                           TIMESTAMPTZ x)
                    throws java.sql.SQLException
Sets the designated parameter to an oracle.sql.TIMESTAMPTZ value.
Parameters:
paramIdx - specifies the parameter index. Index starts from 1.
x - specifies the parameter value.
Throws:
java.sql.SQLException - if an error occurred.
Since:
9i

setTIMESTAMPLTZ

public void setTIMESTAMPLTZ(int paramIdx,
                            TIMESTAMPLTZ x)
                     throws java.sql.SQLException
Sets the designated parameter to an oracle.sql.TIMESTAMPLTZ value.

In order to use this method, the calling program must first set the session time zone of the corresponding connection by using OracleConnection.setSessionTimeZone().

Parameters:
paramIdx - specifies the parameter index. Index starts from 1.
x - specifies the parameter value.
Throws:
java.sql.SQLException - if an error occurred.
Since:
9i

setCheckBindTypes

public void setCheckBindTypes(boolean flag)
Enable/disable bind type checking.

When bind type checking is disabled, the Jdbc driver does not check bind types for every execute. It is intended to be used as a performance enhancement if the user knows for fact that bind types do not change across different executions. The default is true.

Parameters:
flag - Set it to false if Bind Types doesn't change

setPlsqlIndexTable

public void setPlsqlIndexTable(int paramIndex,
                               java.lang.Object arrayData,
                               int maxLen,
                               int curLen,
                               int elemSqlType,
                               int elemMaxLen)
                        throws java.sql.SQLException
Oracle OCI driver specific. Sets the designated PLSQL index table parameter.
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
arrayData - a java array
maxLen - the maximum possible number of elements.
curLen - the current number of elements
elemSqlType - index table element SQL type (as defined in java.sql.Types or OracleTypes).
elemMaxLen - maximum length of the element. If not specified, maximum length allowed for that type is used.
Throws:
java.sql.SQLException - if a database access error occurs
Since:
8.1.7

setFormOfUse

public void setFormOfUse(int paramIndex,
                         short formOfUse)
Set the "Form Of Use" of a column of the PreparedStatement.

This is an Oracle-specific API to allow the user to specify whether a particular data column is of NCHAR, NVARCHAR2 and NCLOB types. In order to put this method in effect, users must invoke this method before setXXX() and registerOutParameter() for the column.

Parameters:
paramIndex - index of the column in the preparedStatment
formOfUse - use FORM_CHAR for CHAR, VARCHAR2 and CLOB data, or FORM_NCHAR for NCHAR, NVARCHAR2 and NCLOB data. FORM_CHAR is the default.
Since:
9i

setDisableStmtCaching

public void setDisableStmtCaching(boolean cache)
Don't Cache this object even when the corresponding Connection is Cache Enabled.
Parameters:
cache - Set it to true, if you don't want this statement to be cached.