Class CResultSet
A CResultSet provides access to a table of data generated by executing a
CStatement. The table rows are retrieved in sequence. Within a row its column
values can be accessed in any order.
A CResultSet maintains a cursor pointing to its current row of data.
Initially the cursor is positioned before the first row. The 'next' method moves
the cursor to the next row.
The getXXX methods retrieve column values for the current row. You can
retrieve values using the index number of the column. Columns are numbered
from 0.
For maximum portability, CResultSet columns within each row should be read in
left-to-right order and each column should be read only once.
For the getXXX methods, the OCI attempts to convert the underlying data
to the specified C++ type and returns a suitable C++ value. See
the OCI specification for allowable mappings from SQL types to C++
types with the CResultSet.getXXX methods.
A CResultSet is automatically closed by the CStatement that generated it when
that CStatement is closed, re-executed, or is used to retrieve the next result
from a sequence of multiple results.
The number, types and properties of a CResultSet's columns are provided by
the CFieldInfo object returned by the getFieldInfo method.
- See Also:
- executeQuery
Constructor Summary |
CResultSet(CStatement* statement)
Constructs a CResultSet object. Your derived class must provide
a constructor that calls this one. |
Method Summary |
void |
close()
Close the resultset. |
private void |
describeResult()
Retrieve information about multiple select-list items. |
int |
getDate(const short, tm*)
Get the value of a column in the current row as a tm
structure. |
double |
getDouble(const short)
Get the value of a column in the current row as a double. |
void |
getFieldInfo(const short, CFieldInfo&)
Returns specific kinds of information about the fields in a
resultset. |
short |
getFieldInfoCount()
Returns the number of fields in the recordset. |
float |
getFloat(const short)
Get the value of a column in the current row as a float. |
int |
getInt(const short)
Get the value of a column in the current row as an int. |
unsigned int |
getLobLenth(const short)
Gets the length of a LOB. |
long double |
getLongDouble(const short)
Get the value of a column in the current row as a long
double. |
char* |
getString(const short, char*, const short) Get the value of a column in the current row as a
String.
|
int |
next() A CResultSet is initially positioned before its
first row; the first call to next makes the first row the current row; the
second call makes the second row the current row, etc.
|
bool |
readClob(const short, char*, const short) Read data from the lob locator.
|
void |
setLobOffset(const short index, const unsigned int
offset = 1) Set the absolute offset from the beginning of the
LOB value.
|
int |
writeClob(const short, const char*, const short)
Write data into the selected lob locator. |
CResultSet::CResultSet
CResultSet(CStatement*
statement);
- Constructs a CResultSet object. You can either use
CResultSet directly or derive an application-specific class from
CResultSet.
- Parameters:
- statement - the CStatement handle.
CResultSet::close
void close();
- Close the resultset.
CResultSet::describeResult
private void describeResult();
- Retrieve information about multiple select-list items.
CResultSet::getDate
int getDate(const short index, tm* time);
- Get the value of a column in the current row as a tm structure.
- Parameters:
- index - the zero-based index of the field.
- time - pointer to a tm structure.
- Returns:
- either the error code or 0 for SQL success.
CResultSet::getDouble
double getDouble(const short index);
- Get the value of a column in the current row as a double.
- Parameters:
- index - the zero-based index of the field.
- Returns:
- the column value; if the value is SQL NULL, the result is 0.
CResultSet::getFieldInfo
void getFieldInfo(const short index, CFieldInfo&
fieldinfo);
- Returns specific kinds of information about the fields in a resultset.
- Parameters:
- index - the zero-based index of the field.
- fieldinfo - a reference to a CFieldInfo structure.
CResultSet::getFieldInfoCount
short getFieldInfoCount ();
- Returns the number of fields in the recordset.
- Returns:
- the number of fields in the recordset.
CResultSet::getFloat
double getFloat(const short index);
- Get the value of a column in the current row as a float.
- Parameters:
- index - the zero-based index of the field.
- Returns:
- the column value; if the value is SQL NULL, the result is 0.
CResultSet::getInt
int getInt(const short index);
- Get the value of a column in the current row as an int.
- Parameters:
- index - the zero-based index of the field.
- Returns:
- the column value; if the value is SQL NULL, the result is
0.
CResultSet::getLobLenth
unsigned int getLobLenth(const short index);
- Gets the length of a LOB.
- Parameters:
- index - the zero-based index of the field.
- Returns:
- the length of the LOB if the LOB is not NULL. For character LOBs, it is the
number of characters, for binary LOBs and BFILEs it is the number of bytes in
the LOB.
CResultSet::getLongDouble
long double getLongDouble(const short index);
- Get the value of a column in the current row as a long double.
- Parameters:
- index - the zero-based index of the field.
- Returns:
- the column value; if the value is SQL NULL, the result is 0.
CResultSet::getString
char* getString(const short index, char* dest, const short len);
- Get the value of a column in the current row as a String.
- Parameters:
- index - the zero-based index of the field.
- dest - buffer into which the converted string is placed.
- len - size of the buffer.
- Returns:
- the destination string. No return value is reserved to indicate an error.
CResultSet::next
int next();
- A CResultSet is initially positioned before its first row; the first call
to next makes the first row the current row; the second call makes the second
row the current row, etc.
- Returns:
- either the error code or 0 for SQL success.
CResultSet::readClob
bool readClob(const short index, char* dest, const short len);
- Read data from the lob locator.
- Parameters:
- index - the zero-based index of the field.
- dest - the pointer to a buffer into which the piece will be read.
- len - the length of the buffer in octets.
- Returns:
- nonzero if the OCI_NEED_DATA error code is returned; otherwise 0.
CResultSet::setLobOffset
void setLobOffset(const short index, const unsigned int
offset);
- Set the absolute offset from the beginning of the LOB value.
- Parameters:
- index - the zero-based index of the field.
- offset - The absolute offset from the beginning of the LOB value.
CResultSet::writeClob
int writeClob (const short index, const char* source, const short len);
- Write data into the selected lob locator.
- Parameters:
- index - the zero-based index of the field.
- source - the pointer to a buffer from which the piece will be written.
- len - the length of the buffer in octets.
- Returns:
- either the error code or 0 for SQL success.
Submit comments/suggestions about
OCL.
Copyright 2001 Sergey Yakovlev. All
Rights Reserved.