|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface extends the OraclePreparedStatement
(which
extends the OracleStatement
interface) and incorporates standard
JDBC callable statement functionality. It is used to execute SQL stored
procedure.
Oracle JDBC drivers support execution of PL/SQL stored procedures and anonymous blocks. They support both SQL92 escape syntax and Oracle PL/SQL block syntax. The following PL/SQL calls would work with any Oracle JDBC driver:
// SQL92 syntax CallableStatement cs1 = conn.prepareCall ( "{call proc (?,?)}" ) ; // stored proc CallableStatement cs2 = conn.prepareCall ( "{? = call func (?,?)}" ) ; // stored func // Oracle PL/SQL block syntax CallableStatement cs3 = conn.prepareCall ( "begin proc (?,?); end;" ) ; // stored proc CallableStatement cs4 = conn.prepareCall ( "begin ? := func(?,?); end;" ) ; // stored func
As an example of using Oracle syntax, here is a PL/SQL code snippet that creates a stored function. The PL/SQL function gets a character sequence and concatenates a suffix to it:
create or replace function foo (val1 char) return char as begin return val1 || 'suffix'; end;
Your invocation call in your JDBC program should look like:
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger"); CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;"); cs.registerOutParameter(1,Types.CHAR); cs.setString(2, "aa"); cs.executeUpdate(); String result = cs.getString(1);
Fields inherited from class oracle.jdbc.OraclePreparedStatement |
FORM_CHAR,
FORM_NCHAR |
Fields inherited from class oracle.jdbc.OracleStatement |
EXPLICIT,
IMPLICIT,
NEW |
Method Summary | |
java.lang.Object |
getAnyDataEmbeddedObject(int parameterIndex)
Retrieves data of an embedded object within AnyData |
ARRAY |
getARRAY(int parameterIndex)
Retrieves data into an oracle.sql.ARRAY object. |
java.io.InputStream |
getAsciiStream(int parameterIndex)
Retrieves data into an java.io.InputStream object. |
BFILE |
getBFILE(int parameterIndex)
Retrieves data into an oracle.sql.BFILE object. |
java.io.InputStream |
getBinaryStream(int parameterIndex)
Retrieves data into an java.io.InputStream object. |
BLOB |
getBLOB(int parameterIndex)
Retrieves data into an oracle.sql.BLOB object. |
CHAR |
getCHAR(int parameterIndex)
Retrieves data into an oracle.sql.CHAR object. |
java.io.Reader |
getCharacterStream(int parameterIndex)
Retrieves data into an java.io.Reader object. |
CLOB |
getCLOB(int parameterIndex)
Retrieves data into an oracle.sql.CLOB object. |
java.sql.ResultSet |
getCursor(int parameterIndex)
Retrieves data into an java.sql.ResultSet object. |
java.lang.Object |
getCustomDatum(int parameterIndex,
CustomDatumFactory factory)
Deprecated. |
DATE |
getDATE(int parameterIndex)
Retrieves data into an oracle.sql.DATE object. |
INTERVALYM |
getINTERVALYM(int parameterIndex)
Retrieves data into an oracle.sql.INTERVALYM object. |
NUMBER |
getNUMBER(int parameterIndex)
Retrieves data into an oracle.sql.NUMBER object. |
OPAQUE |
getOPAQUE(int parameterIndex)
Retrieves data into an oracle.sql.OPAQUE object. |
Datum |
getOracleObject(int parameterIndex)
Retrieves data into an oracle.sql.Datum object. |
Datum[] |
getOraclePlsqlIndexTable(int paramIndex)
Oracle OCI driver specific. |
java.lang.Object |
getORAData(int parameterIndex,
ORADataFactory factory)
|
java.lang.Object |
getPlsqlIndexTable(int paramIndex)
Oracle OCI driver specific. |
java.lang.Object |
getPlsqlIndexTable(int paramIndex,
java.lang.Class primitiveType)
Oracle OCI driver specific. |
RAW |
getRAW(int parameterIndex)
Retrieves data into an oracle.sql.RAW object. |
REF |
getREF(int parameterIndex)
Retrieves data into an oracle.sql.REF object. |
ROWID |
getROWID(int parameterIndex)
Retrieves data into an oracle.sql.ROWID object. |
STRUCT |
getSTRUCT(int parameterIndex)
Retrieves data into an oracle.sql.STRUCT object. |
TIMESTAMP |
getTIMESTAMP(int paramIdx)
Retrieves data into an oracle.sql.TIMESTAMP object. |
TIMESTAMPLTZ |
getTIMESTAMPLTZ(int paramIdx)
Retrieves data into an oracle.sql.TIMESTAMPLTZ object. |
TIMESTAMPTZ |
getTIMESTAMPTZ(int paramIdx)
Retrieves data into an oracle.sql.TIMESTAMPTZ object. |
java.io.InputStream |
getUnicodeStream(int parameterIndex)
Retrieves data into an java.io.InputStream object. |
void |
registerIndexTableOutParameter(int paramIndex,
int maxLen,
int elemSqlType,
int elemMaxLen)
Oracle OCI driver specific. |
void |
registerOutParameter(int paramIndex,
int sqlType,
int scale,
int maxLength)
Special Oracle version of registerOutParameter for registering CHAR, VARCHAR, LONG, RAW and LONG RAW columns. |
void |
registerOutParameterBytes(int paramIndex,
int sqlType,
int scale,
int maxLength)
Special Oracle version of registerOutParameter for registering CHAR, VARCHAR, LONG, RAW and LONG RAW columns. |
void |
registerOutParameterChars(int paramIndex,
int sqlType,
int scale,
int maxLength)
Special Oracle version of registerOutParameter for registering CHAR, VARCHAR, LONG, RAW and LONG RAW columns. |
int |
sendBatch()
Send the sets of parameters batched (for Oracle-style batching only). |
void |
setExecuteBatch(int nrows)
Set the batch value (for Oracle-style batching only). |
Methods inherited from interface java.sql.CallableStatement |
getArray,
getBigDecimal,
getBigDecimal,
getBlob,
getBoolean,
getByte,
getBytes,
getClob,
getDate,
getDate,
getDouble,
getFloat,
getInt,
getLong,
getObject,
getObject,
getRef,
getShort,
getString,
getTime,
getTime,
getTimestamp,
getTimestamp,
registerOutParameter,
registerOutParameter,
registerOutParameter,
wasNull |
Methods inherited from interface oracle.jdbc.OracleStatement |
clearDefines,
closeWithKey,
creationState,
defineColumnType,
defineColumnType,
defineColumnType,
defineColumnTypeBytes,
defineColumnTypeChars,
getRowPrefetch,
isNCHAR,
setResultSetCache,
setRowPrefetch |
Method Detail |
public ARRAY getARRAY(int parameterIndex) throws java.sql.SQLException
oracle.sql.ARRAY
object.parameterIndex
- the first parameter is 1, the second is 2, and so onARRAY
public java.io.InputStream getAsciiStream(int parameterIndex) throws java.sql.SQLException
java.io.InputStream
object.parameterIndex
- the first parameter is 1, the second is 2, and so onjava.io.InputStream
public BFILE getBFILE(int parameterIndex) throws java.sql.SQLException
oracle.sql.BFILE
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.BFILE
public java.io.InputStream getBinaryStream(int parameterIndex) throws java.sql.SQLException
java.io.InputStream
object.parameterIndex
- the first parameter is 1, the second is 2, and so onjava.io.InputStream
public BLOB getBLOB(int parameterIndex) throws java.sql.SQLException
oracle.sql.BLOB
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.BLOB
public CHAR getCHAR(int parameterIndex) throws java.sql.SQLException
oracle.sql.CHAR
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.CHAR
public java.io.Reader getCharacterStream(int parameterIndex) throws java.sql.SQLException
java.io.Reader
object.parameterIndex
- the first parameter is 1, the second is 2, and so onjava.io.Reader
public CLOB getCLOB(int parameterIndex) throws java.sql.SQLException
oracle.sql.CLOB
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.CLOB
public java.sql.ResultSet getCursor(int parameterIndex) throws java.sql.SQLException
java.sql.ResultSet
object.parameterIndex
- the first parameter is 1, the second is 2, and so onjava.sql.ResultSet
public java.lang.Object getCustomDatum(int parameterIndex, CustomDatumFactory factory) throws java.sql.SQLException
parameterIndex
- the first parameter is 1, the second is 2, and so onfactory
- public java.lang.Object getORAData(int parameterIndex, ORADataFactory factory) throws java.sql.SQLException
parameterIndex
- the first parameter is 1, the second is 2, and so onfactory
- public java.lang.Object getAnyDataEmbeddedObject(int parameterIndex) throws java.sql.SQLException
parameterIndex
- the first parameter is 1public DATE getDATE(int parameterIndex) throws java.sql.SQLException
oracle.sql.DATE
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.DATE
public NUMBER getNUMBER(int parameterIndex) throws java.sql.SQLException
oracle.sql.NUMBER
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.NUMBER
public OPAQUE getOPAQUE(int parameterIndex) throws java.sql.SQLException
oracle.sql.OPAQUE
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.OPAQUE
public Datum getOracleObject(int parameterIndex) throws java.sql.SQLException
oracle.sql.Datum
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.Datum
public RAW getRAW(int parameterIndex) throws java.sql.SQLException
oracle.sql.RAW
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.RAW
public REF getREF(int parameterIndex) throws java.sql.SQLException
oracle.sql.REF
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.REF
public ROWID getROWID(int parameterIndex) throws java.sql.SQLException
oracle.sql.ROWID
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.ROWID
public STRUCT getSTRUCT(int parameterIndex) throws java.sql.SQLException
oracle.sql.STRUCT
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.STRUCT
public INTERVALYM getINTERVALYM(int parameterIndex) throws java.sql.SQLException
oracle.sql.INTERVALYM
object.parameterIndex
- the first parameter is 1, the second is 2, and so onoracle.sql.INTERVALYM
public TIMESTAMP getTIMESTAMP(int paramIdx) throws java.sql.SQLException
oracle.sql.TIMESTAMP
object.paramIdx
- the first parameter is 1, the second is 2, and so onoracle.sql.TIMESTAMP
public TIMESTAMPTZ getTIMESTAMPTZ(int paramIdx) throws java.sql.SQLException
oracle.sql.TIMESTAMPTZ
object.paramIdx
- the first parameter is 1, the second is 2, and so onoracle.sql.TIMESTAMPTZ
public TIMESTAMPLTZ getTIMESTAMPLTZ(int paramIdx) throws java.sql.SQLException
oracle.sql.TIMESTAMPLTZ
object.paramIdx
- the first parameter is 1, the second is 2, and so onoracle.sql.TIMESTAMPLTZ
public java.io.InputStream getUnicodeStream(int parameterIndex) throws java.sql.SQLException
java.io.InputStream
object.parameterIndex
- the first parameter is 1, the second is 2, and so onjava.io.InputStream
public void registerOutParameter(int paramIndex, int sqlType, int scale, int maxLength) throws java.sql.SQLException
public void registerOutParameterBytes(int paramIndex, int sqlType, int scale, int maxLength) throws java.sql.SQLException
paramIndex
- parameter index (the first parameter is 1).sqlType
- type of the bind parameterscale
- not usedmaxLength
- maximum length of the column, specified in bytes. If not
specified, maximum length allowed for that type is used.public void registerOutParameterChars(int paramIndex, int sqlType, int scale, int maxLength) throws java.sql.SQLException
paramIndex
- parameter index (the first parameter is 1).sqlType
- type of the bind parameterscale
- not usedmaxLength
- maximum length of the column, specified in characters. If not
specified, maximum length allowed for that type is used.public int sendBatch() throws java.sql.SQLException
Oracle-style batching is not supported for a callable statement. This method simply returns the number of valid rows.
public void setExecuteBatch(int nrows) throws java.sql.SQLException
Oracle-style batching is not supported for a callable statement. This method always sets the batch value to 1.
public java.lang.Object getPlsqlIndexTable(int paramIndex) throws java.sql.SQLException
paramIndex
- the first parameter is 1, the second is 2, and so onpublic java.lang.Object getPlsqlIndexTable(int paramIndex, java.lang.Class primitiveType) throws java.sql.SQLException
paramIndex
- the first parameter is 1, the second is 2, and so onprimitiveType
- is a primitive type class.
For example,java.lang.Double.Typepublic Datum[] getOraclePlsqlIndexTable(int paramIndex) throws java.sql.SQLException
paramIndex
- the first parameter is 1, the second is 2, and so onpublic void registerIndexTableOutParameter(int paramIndex, int maxLen, int elemSqlType, int elemMaxLen) throws java.sql.SQLException
paramIndex
- the first parameter is 1, the second is 2, and so onmaxLen
- the maximum possible number of elements.curLen
- the current number of elementselemSqlType
- 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |