Oracle C++ Call Interface Programmer's Guide Release 2 (9.2) Part Number A96583-01 |
|
OCCI Classes and Methods, 20 of 22
A Statement
object is used for executing SQL statements. The statement may be a query returning result set or a non-query statement returning an update count.
Non-query SQL can be insert, update, or delete statements. Non-query SQL statements can also be DDL statements (such as create, grant, and so on) or stored procedure calls.
A query, insert / update / delete, or stored procedure call statements may have IN bind parameters. A DML returning insert / update / delete statement or stored procedure call may have OUT bind parameters. Finally, a stored procedure call statement may have bind parameters that are both IN and OUT, referred to as IN/OUT parameters.
The Statement
class methods are divided into three categories:
Statement
methods applicable to all statementsTo..., use the syntax:
Statement() enum Status { UNPREPARED, PREPARED, RESULT_SET_AVAILABLE, UPDATE_COUNT_AVAILABLE, NEEDS_STREAM_DATA, STREAM_DATA_AVAILABLE };
After specifying set parameters, an iteration is added for execution.
void addIteration();
In many cases, it is desirable to immediately release a result set's database and OCCI resources instead of waiting for this to happen when it is automatically closed; the closeResultSet
method provides this immediate release.
void closeResultSet(ResultSet *resultSet);
The resultset to be closed. The resultset should have been obtained by a call to the getResultSet
method on this statement.
Closes the stream specified by the parameter stream
.
void closeStream(Stream *stream);
The stream to be closed.
Executes a SQL statement that may return either a result set or an update count. The statement may have read-able streams which may have to be written, in which case the results of the execution may not be readily available. The returned value is one of the following:
UNPREPARED
PREPARED
RESULT_SET_AVAILABLE
UPDATE_COUNT_AVAILABLE
NEEDS_STREAM_DATA
STREAM_DATA_AVAILABLE
If RESULT_SET_AVAILABLE
is returned, the getResultSet()
method must be called to get the result set.
If UPDATE_COUNT_AVAILABLE
is returned, the getUpdateCount
method must be called to find out the update count.
If NEEDS_STREAM_DATA
is returned, output Streams
must be written for the streamed IN
bind parameters. If there is more than one streamed parameter, call the getCurrentStreamParam
method to find out the bind parameter needing the stream. If the statement is executed iteratively, call getCurrentIteration
to find out the iteration for which stream needs to be written.
If STREAM_DATA_AVAILABLE
is returned, input Streams
must be read for the streamed OUT
bind parameters. If there is more than one streamed parameter, call the getCurrentStreamParam
method to find out the bind parameter needing the stream. If the statement is executed iteratively, call getCurrentIteration
to find out the iteration for which stream needs to be read.
If only one OUT
value is returned for each invocation of the DML returning statement, iterative executes can be performed for DML returning statements. If output streams are used for OUT
bind variables, they must be completely read in order. The getCurrentStreamParam
method would indicate which stream needs to be read. Similarly, getCurrentIteration
would indicate the iteration for which data is available.
Returns
RESULT_SET_AVAILABLE
-- call getResultSet()
UPDATE_COUNT_AVAILABLE
-- call getUpdateCount()
NEEDS_STREAM_DATA
-- call getCurrentStream()
and getCurrentIteration()
, and write
(or read
) streamStatus execute(const string &sql = "");
The SQL statement to be executed. This can be null if the setSQL
method was used to associate the sql with the statement.
Executes insert/update/delete statements which use only the setDataBuffer() or stream interface for bind parameters. The bind parameters must be arrays of size arrayLength parameter. The statement may have read-able streams which may have to be written. The returned value is one of the following:
If UPDATE_COUNT_AVAILABLE
is returned, getUpdateCount()
must be called to find out the update count.
If NEEDS_STREAM_DATA
is returned, output Streams
must be written for the streamed bind parameters. If there is more than one streamed parameter, getCurrentStreamParam()
can be called to find out the bind parameter needing the stream. The getCurrentIteration()
can be called to find out the iteration for which stream needs to be written.
If STREAM_DATA_AVAIALBE
is returned, input Streams
must be read for the streamed OUT
bind parameters. If there is more than one streamed parameter, getCurrentStreamParam()
can be called to find out the bind parameter needing the stream. If the statement is executed iteratively, getCurrentIteration()
can be called to find out the iteration for which stream needs to be read.
If only one OUT
value is returned for each invocation of the DML returning statement, array executes can be done for DML returning statements also. If output streams are used for OUT
bind variables, they must be completely read in order. The getCurrentStreamParam()
method would indicate which stream needs to be read. Similarly, getCurrentIteration()
would indicate the iteration for which data is available.
Note that you cannot perform array executes for queries or callable statements.
Status executeArrayUpdate(unsigned int arrayLength);
The number of elements provided in each buffer of bind variables. The statement is executed this many times with each array element used for each iteration. Returns:
UPDATE_COUNT_AVAILABLE
-- call getUpdateCount()
NEEDS_STREAM_DATA
-- call getCurrentStream()
and getCurrentIteration()
, and write
(or read
) streamExecute a SQL statement that returns a ResultSet
. Should not be called for a statement which is not a query, has streamed parameters. Returns a ResultSet
that contains the data produced by the query
ResultSet * executeQuery(const string &sql = "");
sql statement to be executed. This can be null if setSQL() was used to associate the sql with the statement.
Executes a non-query statement such as a SQL INSERT
, UPDATE
, DELETE
statement, a DDL statement such as CREATE
/ALTER
and so on, or a stored procedure call. Returns either the row count for INSERT
, UPDATE
or DELETE
or 0 for SQL statements that return nothing
unsigned int executeUpdate(const string &sql = "");
The SQL statement to be executed. This can be null if the setSQL
method was used to associate the sql with the statement.
Get the current auto-commit state. Returns Current state of auto-commit mode.
bool getAutoCommit() const;
Get the value of a BFILE
parameter as a Bfile
object. Returns the parameter value.
Bfile getBfile(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a BLOB
parameter as a Blob
. Returns the parameter value
Blob getBlob(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a SQL BINARY or VARBINARY
parameter as Bytes
. Returns the parameter value; if the value is SQL null, the result is null.
Bytes getBytes(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Returns the character set that is in effect for the specified parameter, as a string.
string getCharSet(unsigned int paramIndex) const;
The first parameter is 1, the second is 2, . . . .
Get the value of a CLOB
parameter as a Clob
. Returns the parameter value.
Clob getClob(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
const Connection* getConnection() const;
If the prepared statement has any output Streams
, this method returns the current iteration of the statement that is being processed by OCCI. If this method is called after all the invocations in the set of iterations has been processed, it returns 0. Returns the iteration number of the current iteration that is being processed. The first iteration is numbered 1 and so on. If the statement has finished execution, a 0 is returned.
unsigned int getCurrentIteration() const;
Returns the current param stream for which data is available.
unsigned int getCurrentStreamIteration() const;
If the prepared statement has any output Stream
parameters, this method returns the parameter index of the current output Stream
that must be written. If no output Stream
needs to be written, or there are no output Stream
parameters in the prepared statement, this method returns 0.
Returns the parameter index of the current output Stream
parameter that must be written.
unsigned int getCurrentStreamParam() const;
Get the REF
CURSOR
value of an OUT
parameter as a ResultSet
. Data can be fetched from this result set. The OUT
parameter must be registered as CURSOR
with the Statement
.registerOutParam
(int
paramIndex
, CURSOR
) method. Note that if there are multiple REF
CURSORs
being returned due to a batched call, data from each cursor must be completely fetched before retrieving the next REF
CURSOR
and starting fetch on it. Returns A ResultSet
for the OUT
parameter value.
ResultSet * getCursor(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Returns whether data is in NCHAR character set or not.
bool getDatabaseNCHARParam(unsigned int paramIndex) const;
The first parameter is 1, the second is 2, . . . .
Get the value of a SQL DATE
parameter as a Date
object. Returns the parameter value; if the value is SQL null, the result is null.
Date getDate(unsigned int paramIndex) const;
the first parameter is 1, the second is 2, . . . .
Get the value of a DOUBLE
parameter as a C++ double. Returns the parameter value; if the value is SQL null, the result is 0.
double getDouble(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a FLOAT parameter as a C++ float. Returns the parameter value; if the value is SQL null, the result is 0.
float getFloat(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of an INTEGER
parameter as a C++ int. Returns the parameter value; if the value is SQL null
, the result is 0
unsigned int getInt(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a parameter as a IntervalDS
object.
IntervalDS getIntervalDS(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a parameter as a IntervalYM
object.
IntervalYM getIntervalYM(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Gets the current limit on maximum number of iterations. Default is 1. Returns the current maximum number of iterations.
unsigned int getMaxIterations() const;
The maxParamSize
limit (in bytes) is the maximum amount of data sent or returned for any parameter value; it only applies to character and binary types. If the limit is exceeded, the excess data is silently discarded. Returns the current max parameter size limit
unsigned int getMaxParamSize(unsigned int paramIndex) const;
The first parameter is 1, the second is 2, . . . .
Get the value of a NUMERIC
parameter as a Number
object. Returns the parameter value; if the value is SQL nullnull
, the result is null.
Number getNumber(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a parameter as a PObject
. This method returns an PObject
whose type corresponds to the SQL type that was registered for this parameter using registerOutParam
. Note that this method may be used to read database-specific, abstract data types. Returns A PObject
holding the OUT
parameter value.
PObject * getObject(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the OCI statement handle associated with the Statement
. Returns the OCI statement handle associated with the Statement
LNOCIStmt * getOCIStatement() const;
Get the value of a REF
parameter as RefAny
. Returns the parameter value.
RefAny getRef(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Returns the current result as a ResultSet
.
ResultSet * getResultSet();
Get the rowid
param value as a Bytes
Bytes getRowid(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Returns the current SQL string associated with the Statement object.
string getSQL() const;
Stream * getStream(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a CHAR
, VARCHAR
, or LONGVARCHAR
parameter as an string. Returns the parameter value; if the value is SQL null
, the result is empty string.
string getString(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a SQL TIMESTAMP parameter as a Timestamp object. Returns the parameter value; if the value is SQL null
, the result is null
Timestamp getTimestamp(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Get the value of a BIGINT
parameter as a C++ unsigned int. Returns the parameter value; if the value is SQL null
, the result is 0
unsigned int getUInt(unsigned int paramIndex);
The first parameter is 1, the second is 2, . . . .
Returns the current result as an update count.
unsigned int getUpdateCount() const;
This method returns the column in the current position as a vector. The column at the position , specified by index, should be a collection type (varray
or nested table). The SQL type of the elements in the collection should be compatible with the type of the vector
There are variant of syntax:
void getVector(Statement *stmt, unsigned int paramIndex, vector<int> &vect;
void getVector(Statement *stmt, unsigned int paramindex, vector<string> &vect;
void getVector(Statement *stmt, unsigned int index, vector<unsigned int> &vect;
void getVector(Statement *stmt, unsigned int paramindex, vector<float> &vect;
void getVector(Statement *stmt, unsigned int paramindex, vector<double> &vect;
void getVector(Statement *stmt, unsigned int paramindex, vector<Date> &vect;
void getVector(Statement *stmt, unsigned int paramindex, vector<Timestamp> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<RefAny> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<Blob> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<Clob> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<Bfile> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<Number> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<IntervalDS> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<IntervalYM> &vect;
void getVector(Statement *stmt, unsigned int paramIndex, vector<T *> &vect);
void getVector(Statement *stmt, unsigned int paramIndex, vector<T> &vect);
In particular, the last two variants are identical. The former is intended for use on platforms where partial ordering of function templates is supported and the latter on those it is not.
Similarly, the variant
void getVector(Statement *stmt, unsigned int paramIndex, vector< Ref<T> > &vect);
is available only on platforms where partial ordering of function templates is supported. This function may be deprecated in the future. getVectorOfRefs() can be used instead.
statement
The first parammeter is 1, second parameter is 2, ...
Reference to the vector (OUT parameter) into which the values should be retrieved.
This method returns the column in the current position as a vector of REFs. The column should be a collection type (varray or nested table) of REFs.
void getVectorOfRefs(Statement *stmt, unsigned int index, vector< Ref<T> > &vect);
The statement.
The column index (the first column is 1, the second is 2, . . . . )
The reference to the vector of REFs (OUT parameter).
It is recommended to use getVectorOfRefs
instead of specialized getVector
function for Ref<T>.
An OUT
parameter may have the value of SQL null
; wasNull
reports whether the last value read has this special value. Note that you must first call getXXX
on a parameter to read its value and then call wasNull() to see if the value was SQL null
. Returns true
if the last parameter read was SQL null
bool isNull(unsigned int paramIndex ) const;
The first parameter is 1, the second is 2, . . . .
This method checks whether the value of the parameter is truncated. If the value of the parameter is truncated, then true is returned; otherwise, false is returned.
bool isTruncated(unsigned int paramIndex) const;
The first parameter is 1, the second is 2, . . . .
Returns the actual length of the parameter before truncation.
int preTruncationLength(unsigned int paramIndex) const;
The first parameter is 1, the second is 2, . . . .
This method registers the type
of each out
paramater of a PL/SQL stored procedure. Before executing a PL/SQL stored procedure, you must explicitly call this method to register the type
of each out
parameter. This method should be called for out
parameters only. Use the set
xxx
method for in/out parameters.
When reading the value of an out
parameter, you must use the get
xxx
method that corresponds to the parameter's registered SQL type. For example, use getInt
or getNumber
when OCCIINT
or OCCINumber
is the type specified.
If a PL/SQL stored procedure has an out
paramater of type
ROWID
, the type
specified in this method should be OCCISTRING
. The value of the out
parameter can then be retrieved by calling the getString()
method.
If a PL/SQL stored procedure has an in/out parameter of type ROWID
, call the methods setString()
and getString()
to set the type and retrieve the value of the in/out parameter.
void registerOutParam(unsigned int paramIndex, Type type, unsigned int maxSize = 0, const string &sqltype = "");
The first parameter is 1, the second is 2, . . . .
SQL type code defined by type
; only datatypes corresponding to OCCI data types such as Date
, Bytes
, and so on.
The maximum size of the retrieved value. For datatypes of OCCIBYTES
and OCCISTRING
, maxSize
should be greater than 0.
The name of the type in the data base (used for types which have been created with CREATE
TYPE
)
A Statement
can be in auto-commit mode. In this case any statement executed is also automatically committed. By default, the auto-commit mode is turned-off.
void setAutoCommit(bool autoCommit);
True
enables auto-commit; false
disables auto-commit.
Set a parameter to a Bfile
value.
void setBfile(unsigned int paramIndex, const Bfile &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Defines that a column is to be returned as a binary stream by the getStream
method.
void setBinaryStreamMode(unsigned int colIndex, unsigned int size);
Column to be bound as a stream. The first column is 1, the second is 2, . . . .
The amount of data to be read or returned as a binary stream.
Set a parameter to a Blob
value.
void setBlob(unsigned int paramIndex, const Blob &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a Bytes
array.
void setBytes(unsigned int paramIndex, const Bytes &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Defines that a column is to be returned as a character stream by the getStream
method.
void setCharacterStreamMode(unsigned int colIndex, unsigned int size);
The first column is 1, the second is 2, . . . .
Overrides the default character set for the specified parameter. Data is assumed to be in the specified character set and is converted to database character set. For OUT binds, this specifies the character set to which database characters are converted to.
void setCharSet(unsigned int paramIndex, string charSet);
The first parameter is 1, the second is 2, . . . .
Selected character set, as a string.
Set a parameter to a Clob
value.
void setClob(unsigned int paramIndex, const Clob &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a Date
value.
void setDate(unsigned int paramIndex, const Date &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
If the parameter is going to be inserted in a column that contains data in the database's NCHAR
character set, then OCCI must be informed by passing a true
value. A false
can be passed to restore the dafault.Returns returns the character set that is in effect for the specified parameter.
void setDatabaseNCHARParam(unsigned int paramIndex, bool isNCHAR);
The first parameter is 1, the second is 2, . . . .
True
if this parameter contains data in Database's NCHAR
character set; false
otherwise.
Specify a data buffer where data would be available. Also, used for OUT
bind parameters of callable statements (and DML returning OUT
binds in future).
The buffer
parameter is a pointer to a user allocated data buffer. The current length of data must be specified in the *length
parameter. The amount of data should not exceed the size
parameter. Finally, type
is the data type of the data.
Note that not all types
can be supplied in the buffer. For example, all OCCI allocated types (such as Bytes
, Date
and so on.) cannot be provided by the setDataBuffer
interface. Similarly, C++ Standard Library strings cannot be provided with the setDataBuffer
interface either. The type
can be any of OCI data types such VARCHAR2
, CSTRING
, CHARZ
and so on.
If setDataBuffer
() is used to specify data for iterative or array executes, it should be called only once in the first iteration only. For subsequent iterations, OCCI would assume that data is at buffer + i*size
location where i is the iteration number. Similarly the length of the data would be assumed to be at *(length + i)
.
void setDataBuffer(unsigned int paramIndex, void *buffer, Type type, sb4 size, ub2 *length, sb2 *ind =NULL
, ub2 *rc=NULL
);
The first parameter is 1, the second is 2, . . . .
Pointer to user-allocated buffer; if iterative or array executes are done, it should have numIterations * size bytes in it.
Type of the data that is provided (or retrieved) in the buffer
Size of the data buffer; for iterative and array executes, it is the size of each element of the data items
Pointer to the length of data in the buffer; for iterative and array executes, it should be an array of length data for each buffer element; the size of the array should be equal to arrayLength.
Indicator. For iterative and array executes, an indicator for every buffer element
Return code -- for iterative and array executes, a return code for every buffer element
Specify an array of data buffers where data would be available for reading or writing. Used for IN
, OUT
, and IN/OUT
bind parameters for stored procedures which read/write array parameters.
A stored procedure can have an array of values for IN
, IN/OUT
, or OUT
parameters. In this case, the parameter must be specified using the setDataBufferArray
() method. The array is specified just as for the setDataBuffer()
method for iterative or array executes, but the number of elements in the array is determined by *arrayLength
parameter.
For OUT
and IN/OUT
parameters, the maximum number of elements in the array is specified by the arraySize
parameter. Note that for iterative prepared statements, the number of elements in the array is determined by the number of iterations, and for array executes the number of elements in the array is determined by the arrayLength
parameter of the executeArrayUpdate
() method. However, for array parameters of stored procedures, the number of elements in the array must be specified in the *arrayLength
parameter of the setDataBufferArray()
method because each parameter may have a different size array.
This is different from prepared statements where for iterative and array executes, the number of elements in the array for each parameter is the same and is determined by the number of iterations of the statement, but a callable statement is executed only once, and each of its parameter can be a varying length array with possibly a different length.
Note that for OUT
and IN/OUT
binds, the number of elements returned in the array is returned in *arrayLength
as well. The client must make sure that it has allocated elementSize * arraySize
bytes for the buffer
.
void setDataBufferArray(unsigned int paramIndex, void *buffer, Type type, ub4 arraySize, ub4 *arrayLength, sb4 elementSize, ub2 *elementLength, sb2 *ind =NULL
, ub2 *rc =NULL
);
The first parameter is 1, the second is 2, . . . .
Pointer to user-allocated buffer. It should have size * arraySize
bytes in it
Type of the data that is provided (or retrieved) in the buffer
Maximum number of elements in the array
Pointer to number of current elements in the array
Size of the data buffer for each element
Pointer to an array of lengths. elementLength[i]
has the current length of the ith element of the array.
Pointer to an array of indicators. An indicator for every buffer element.
Pointer to an array of return codes.
Set a parameter to a C++ double value.
void setDouble(unsigned int paramIndex, double x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Enables/disables exceptions for reading of null
values on paramIndex parameter of the statement. If exceptions are enabled, calling a get
xxx
on paramIndex
parameter would result in an SQLException
if the parameter value is null. This call can also be used to disable exceptions.
void setErrorOnNUll(unsigned int paramIndex, bool causeException);
The first parameter is 1, the second is 2, . . . .
Enable exceptions if true
, disable if false
This method enables/disables exceptions when truncation occurs.
void setErrorOnTruncate(unsigned int paramIndex, bool causeException);
The first parameter is 1, the second is 2, . . . .
Enable exceptions if true
. Disable if false.
Set a parameter to a C++ float value.
void setFloat(unsigned int paramIndex, float x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a C++ int value.
void setInt(unsigned int paramIndex, int x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a IntervalDS
value.
void setIntervalDS(unsigned int paramIndex, const IntervalDS &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a Interval
value.
void setIntervalYM(unsigned int paramIndex, const IntervalYM &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Sets the maximum number of invocations that will be made for the DML statement. This must be called before any parameters are set on the prepared statement. The larger the iterations, the larger the numbers of parameters sent to the server in one round trip. However, a large number causes more memory to be reserved for all the parameters. Note that this is just the maximum limit. Actual number of iterations depends on the number of addIterations()
that are done.
void setMaxIterations(unsigned int maxIterations);
Maximum number of iterations allowed on this statement.
This method sets the maximum amount of data to be sent or received for the specified parameter. It only applies to character and binary data. If the maximum amount is exceeded, the excess data is discarded. This method can be very useful when working with a LONG
column. It can be used to truncate the LONG
column by reading or writing it into a string or Bytes
data type.
If the setString
or setBytes
method has been called to bind a value to an IN/OUT parameter of a pl/sql procedure, and the size of the OUT value is expected to be greater than the size of the IN value, then setMaxParamSize
should be called.
void setMaxParamSize(unsigned int paramIndex, unsigned int maxSize);
The first parameter is 1, the second is 2, . . . .
The new max parameter size limit (> 0) .
Set a parameter to SQL null. Note that you must specify the parameter's SQL type.
void setNull(unsigned int paramIndex, Type type);
The first parameter is 1, the second is 2, . . . .
SQL type code defined by Type
Set a parameter to a Number
value.
void setNumber(unsigned int paramIndex, const Number &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set the value of a parameter using an object; use the C++.lang equivalent objects for integral values. The OCCI specification specifies a standard mapping from C++ Object
types to SQL types. The given parameter C++ object will be converted to the corresponding SQL type before being sent to the database.
void setObject(unsigned int paramIndex, PObject * x);
The first parameter is 1, the second is 2, . . . .
The object containing the input parameter value.
Set the amount of memory that will be used internally by OCCI to store data fetched during each round trip to the server. A value of 0 means that the amount of data fetched during the round trip is constrained by the FetchRowCount
parameter. If both parameters are nonzero, the smaller of the two is used.
void setPrefetchMemorySize(unsigned int bytes);
Number of bytes to use for storing data fetched during each round trip to the server.
Set the number of rows that will be fetched internally by OCCI during each round trip to the server. A value of 0 means that the amount of data fetched during the round trip is constrained by the FetchMemorySize
parameter. If both parameters are nonzero, the smaller of the two is used. If both of these parameters are zero, row count internally defaults to 1 row and that is the value returned from the getFetchRowCount
method.
void setPrefetchRowCount(unsigned int rowCount);
Number of rows to fetch for each round trip to the server.
Set a parameter to a RefAny
value.
void setRef(unsigned int paramIndex, RefAny &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a Rowid
bytes array for a bind position.
void setRowid(unsigned int paramIndex, const Bytes &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
A new SQL string can be associated with a Statement
object by this call. Resources associated with the previous SQL statement are freed. In particular, a previously obtained result set is invalidated. If an empty sql string, "", was used when the Statement
was created, a setSQL
method with the proper SQL string must be done prior to execution.
void setSQL(const string &sql);
Any SQL statement.
Set a parameter to an string value.
void setString(unsigned int paramIndex, const string &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a Timestamp
value.
void setTimestamp(unsigned int paramIndex, const Timestamp &x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
Set a parameter to a C++ unsigned int value.
void setUInt(unsigned int paramIndex, unsigned int x);
The first parameter is 1, the second is 2, . . . .
The parameter value.
This method sets a parameter to a vector. This method should be used when the type is a collection type -- varrays or nested tables. The SQL Type of the elements in the collection should be compatible with the type of the vector. For example, if the collection is a varray of VARCHAR2, use vector<string>
There are variants of syntax:
void setVector(Statement *stmt, unsigned int paramIndex, vector<int> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<unsigned int> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<double> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<float> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<string> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<RefAny> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Blob> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Clob> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Bfile> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Timestamp> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<IntervalDS> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<IntervalYM> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Date> &vect, string sqltype);
void setVector(Statement *stmt, unsigned int paramIndex, vector<Number> &vect, string sqltype);
template <class T> void setVector( Statement *stmt, unsigned int paramIndex, const OCCI_STD_NAMESPACE::vector< T > &vect, const OCCI_STD_ NAMESPACE::string &sqltype) ;
template <class T> void setVector( Statement *stmt, unsigned int paramIndex, const OCCI_STD_NAMESPACE::vector<T* > &vect, const OCCI_STD_NAMESPACE::string &sqltype) ;
In particular, the last two variants are identical. The former is intended for use on platforms where partial ordering of function templates is supported and the latter on those it is not.
Similarly, the variant
void setVector(Statement *stmt, unsigned int paramIndex, vector<Ref<T>> &vect, string sqltype);
is available only on platforms where partial ordering of function templates is supported. This function may be deprecated in the future. setVectorOfRefs()
can be used instead.
statement on which parameter is to be set.
parameter index , first parameter is 1, second is 2, ...
vector to be set.
sqltype of the parameter/column.
For example, CREATE TYPE num_coll AS VARRAY OF NUMBER. And the column/parameter type is num_coll. The sqltype would be num_coll.
This method sets a parameter to a vector . This method should be used when the type is a collection of REFs -- varrays or nested tables of REFs
template <class T> void setVectorOfRefs(Statement *stmt, unsigned int paramIndex, const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect, const OCCI_STD_NAMESPACE::string &sqltype) ;
statement on which parameter is to be set.
parameter index , first parameter is 1, second is 2, ...
vector to be set
sqltype of the parameter/column.
It is recommened to use setVectorOfRefs insetad of specialised function setVector for Ref<T>.
Returns the current status of the statement. Useful when there is streamed data to be written (or read). Other methods such as getCurrentStreamParam
and getCurrentIteration
can be called to find out the streamed parameter that needs to be written and the current iteration number for an iterative or array execute.
The status
method can be called repeatedly to find out the status of the execution. Returns one of following:
RESULT_SET_AVAILABLE
-- call getResultSet()
UPDATE_COUNT_AVAILABLE
-- call getUpdateCount()
NEEDS_STREAM_DATA
-- call getCurrentStream()
and getCurrentIteration()
, and write streamSTREAM_DATA_AVAILABLE
-- call getCurrentStream()
and getCurrentIteration()
, and read streamPREPARED
UNPREPARED
Status status() const;
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|