OCILIB (C and C++ Driver for Oracle)  4.0.0
ocilib::Resultset Class Reference

Database resultset. More...

#include <ocilib.hpp>

Inherits ocilib::HandleHolder< OCI_Resultset * >.

Public Types

enum  SeekModeValues { SeekAbsolute = OCI_SFD_ABSOLUTE, SeekRelative = OCI_SFD_RELATIVE }
 Seek Modes enumerated values. More...
 
typedef Enum< SeekModeValuesSeekMode
 Seek Modes. More...
 

Public Member Functions

template<class TDataType >
TDataType Get (unsigned int index) const
 Return the current value of the column at the given index in the resultset. More...
 
template<class TDataType >
TDataType Get (const ostring &name) const
 Return the current value of the column from its name in the resultset. More...
 
bool Next ()
 Fetch the next row of the resultset. More...
 
bool Prev ()
 Fetch the previous row of the resultset. More...
 
bool First ()
 Fetch the first row of the resultset. More...
 
bool Last ()
 Fetch the last row of the resultset. More...
 
bool Seek (SeekMode mode, int offset)
 Custom Fetch of the resultset. More...
 
unsigned int GetCount () const
 Retrieve the number of rows fetched so far.
 
unsigned int GetCurrentRow () const
 Retrieve the current row index. More...
 
unsigned int GetColumnIndex (const ostring &name) const
 Return the index of the column in the result from its name. More...
 
unsigned int GetColumnCount () const
 Return the number of columns in the resultset.
 
Column GetColumn (unsigned int index) const
 Return the column from its index in the resultset. More...
 
Column GetColumn (const ostring &name) const
 Return the column from its name in the resultset. More...
 
bool IsColumnNull (unsigned int index) const
 Check if the current row value is null for the column at the given index. More...
 
bool IsColumnNull (const ostring &name) const
 Check if the current row value is null for the column of the given name. More...
 
Statement GetStatement () const
 Return the statement associated with the resultset.
 
bool operator++ (int)
 Convenient operator overloading that performs a call to Next()
 
bool operator-- (int)
 Convenient operator overloading that performs a call to Prev()
 
bool operator+= (int offset)
 Convenient operator overloading that performs a call to Seek() with Resultset::SeekRelative and the given offset.
 
bool operator-= (int offset)
 Convenient operator overloading that performs a call to Seek() with Resultset::SeekRelative and the given offset that is internally negated.
 

Detailed Description

Database resultset.

This class wraps the OCILIB object handle OCI_Resultset and its related methods

Definition at line 5716 of file ocilib.hpp.

Member Typedef Documentation

Seek Modes.

Possible values are Resultset::SeekModeValues

Definition at line 5741 of file ocilib.hpp.

Member Enumeration Documentation

Seek Modes enumerated values.

Enumerator
SeekAbsolute 

Seek is performed using a given absolute offset. The statement must be scrollable

SeekRelative 

Seek is performed using a given relative offset from the current position. The statement must be scrollable

Definition at line 5726 of file ocilib.hpp.

Member Function Documentation

template<class TDataType >
TDataType ocilib::Resultset::Get ( unsigned int  index) const
inline

Return the current value of the column at the given index in the resultset.

Template Parameters
TDataType- C++ type of the value to retrieve
Parameters
index- Column position
Warning
This method has builtin specialized versions for all supported types except RAW based types. For RAWS, use the version with extra parameters
Note
Column position starts at 1.

Definition at line 5246 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetColl().

template<class TDataType >
TDataType ocilib::Resultset::Get ( const ostring name) const
inline

Return the current value of the column from its name in the resultset.

Template Parameters
TDataType- C++ type of the value to retrieve
Parameters
name- Column name
Warning
This method has builtin specialized versions for all supported types except RAW based types. For RAWS, use the version with extra parameters
Note
The column name is case insensitive.

Definition at line 5252 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetColl2().

bool ocilib::Resultset::Next ( )
inline

Fetch the next row of the resultset.

Note
Next() works for normal and scrollable resultsets
Returns
true on success otherwise false if :
  • Empty resultset
  • Last row already fetched

Definition at line 4879 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_FetchNext().

bool ocilib::Resultset::Prev ( )
inline

Fetch the previous row of the resultset.

Note
Prev() works ONLY for scrollable resultsets
Returns
true on success otherwise false if :
  • Empty resultset
  • First row already fetched

Definition at line 4884 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_FetchPrev().

bool ocilib::Resultset::First ( )
inline

Fetch the first row of the resultset.

Note
First() works ONLY for scrollable resultsets
Returns
true on success otherwise false if the resultset is empty

Definition at line 4889 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_FetchFirst().

bool ocilib::Resultset::Last ( )
inline

Fetch the last row of the resultset.

Note
Last() works ONLY for scrollable resultsets
Returns
true on success otherwise false if the resultset is empty

Definition at line 4894 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_FetchLast().

bool ocilib::Resultset::Seek ( SeekMode  mode,
int  offset 
)
inline

Custom Fetch of the resultset.

Parameters
mode- Fetch direction
offset- Fetch offset
Warning
hSeek() works ONLY for scrollable resultsets
Note
If you intend to use Seek() on a scrollable statement and if any of the selected columns is a ref cursor or a nested table, you must set the fetching size to 1 using Statement::SetFetchSize() before calling Statement::GetResultset() Otherwise Seek() will fails with a OCI-10002 error
Returns
true on success otherwise false the resultset is empty or seek offset out of bounds

Definition at line 4899 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_FetchSeek().

unsigned int ocilib::Resultset::GetCurrentRow ( ) const
inline

Retrieve the current row index.

Note
  • GetCurrentRow() returns the current row number starting from 1
  • If the resultset has not been fetched or if the resultset is empty, it returns 0
  • If the resultset has been fully fetched, it returns the last fetched row number

Definition at line 4909 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetCurrentRow().

unsigned int ocilib::Resultset::GetColumnIndex ( const ostring name) const
inline

Return the index of the column in the result from its name.

Parameters
name- Column name
Warning
The column name is case insensitive
Note
Column position starts at 1.

Definition at line 4914 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetColumnIndex().

Column ocilib::Resultset::GetColumn ( unsigned int  index) const
inline

Return the column from its index in the resultset.

Parameters
index- Column index
Note
Column position starts at 1.

Definition at line 4924 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetColumn().

Column ocilib::Resultset::GetColumn ( const ostring name) const
inline

Return the column from its name in the resultset.

Parameters
name- Column name
Note
The column name is case insensitive

Definition at line 4929 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_GetColumn2().

bool ocilib::Resultset::IsColumnNull ( unsigned int  index) const
inline

Check if the current row value is null for the column at the given index.

Parameters
index- Column index
Note
Column position starts at 1.

Definition at line 4934 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IsNull().

bool ocilib::Resultset::IsColumnNull ( const ostring name) const
inline

Check if the current row value is null for the column of the given name.

Parameters
name- Column name

Definition at line 4939 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_IsNull2().