| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes
TeOCICursor Class Reference

A class that implements a concept of record set to a ORACLE DBMS. More...

`#include <TeOCICursor.h>`

List of all members.

## Public Member Functions

| TeOCICursor (TeOCIConnection *conn, const unsigned long &maxBlobSize=0, const unsigned long &maxRowNum=0)
| Constructor.
| ~TeOCICursor ()
| Destructor.
bool | open ()
| Opens the cursor locating memory and initializing the enviroment.
string | getErrorMessage ()
| Returns the error message.
bool | isOpen ()
| Checks if the cursor is opened.
TeOCIConnection * | conn ()
| Returns the connection to the database server.
int | currentRow ()
| Returns the current row index.
void | close ()
| Closes the cursor.
void | defineByPos (int pos, void *value, int size, void *indicator, int type)
| Defines the OCI handles by position.
bool | execute ()
| Executes the SQL statement set previously.
bool | fetch (int rows)
| Fetchs a number of rows.
bool | query (const string &query)
| Executes a query defined by a SQL statement that returns a record set as result.
bool | querySDO (const string &query)
| Executes a query defined by a SQL statement that uses SDO_GEOMETRY type and returns a record set as result.
bool | moveFirst ()
| Moves to the first row in the record set.
bool | moveNext ()
| Moves to the next row in the record set.
bool | moveTo (int pos)
| Moves to a specific position in the record set.
bool | moveLast ()
| Moves to the last row in the record set.
bool | appendOrdinates (const double &val)
| Appends the new value to the internal ordinate vector.
bool | bindOrdinates ()
| Binds the internal ordinate array with the SQL statement.
bool | prepare (const string &stmt)
| Sets and prepares the SQL statement to be executed.
int | queryType ()
| Returns the query type based on the SQL statement set previously.
bool | allocateCursor (void)
| Locates memory to store the record set in the client side.
char * | getFieldValue (int i)
| Gets the i-th field value from record set.
void | freeResult (void)
| Clears the memory and structures located by the record set.
Methods to return information about the columns and rows in the record set
int | colType (int colnumber)
| Returns the column type (SQLT) of a specific column.
string | colName (int colnumber)
| Returns the column name of a specific column.
int | colSize (int colnumber)
| Returns the column size of a specific column.
int | colScale (int colnumber)
| Returns the column scale (number of digits after decimal point) of a specific column.
int | numCol (void)
| Returns the columns number in the client side.
void | loadCollDescription ()
| Loads all column descriptions (name, type, size and scale)
int | numRows (void)
| Returns the rows number in the client side.
Methods to deal with SDO_GEOMETRY, SDO_ELEM_INFO and SDO_ORDINATES types of the Oracle Spatial
int | getDimArraySize ()
| Gets the size of the SDO_ELEM_INFO array of the record set current row.
bool | getDimElement (int i, int &elem)
| Gets the i-th element of the SDO_ELEM_INFO array of the record set current row.
int | getNumberOrdinates (void)
| Gets the number of ordinates in the SDO_ORDINATES array of the record set current row.
bool | getCoordinates (int i, TeCoord2D &coord)
| Gets the i-th coordinate of the SDO_ORDINATES array of the record set current row.
bool | getCoordinates (vector< TeCoord2D > &result)
| Gets all coordinates of the SDO_ORDINATES array of the record set current row.
int | getGeometryType ()
| Gets the geometry type of the SDO_GEOMETRY type of the record set current row.
int | getSpatialReferenceId ()
| Gets the spatial reference of the SDO_GEOMETRY type of the record set current row.
bool | getXYZcoord (double &x, double &y)
| Gets a coordinate (x and y) of the SDO_POINT type of the record set current row.
Methods to deal with long binary (blob) type
bool | readBlob (unsigned char *buffer, unsigned int &bufsize, unsigned int &blobCol)
| Reads a long binary (blob) column (blobCol) from database server and returns it as a unsigned char vector.
bool | readBlob (unsigned char *buffer, unsigned int &bufsize, const string &blobCol)
| Reads a long binary (blob) column (blobCol) from database server and returns it as a unsigned char vector.
bool | readBlob (double *buffer, unsigned int &bufsize)
| Reads a long binary (blob) from database server and returns it as a double vector.
bool | readBlob (double **buffer)
| Gets a pointer to buffer of blob.
unsigned int | getBlobSize (const string &blobCol)
| Returns the size (in unsigend int) of a specific blob column.

## Protected Member Functions

bool | checkError (sword status)
| Checks the error associated to error OCI handle.

## Protected Attributes

TeOCIConnection * | connection_
| A pointer to a opened connection.
OCIStmt * | stmthpToQuery_
| OCI statement handle to query.
OCIDescribe * | dschp_
| OCI environment describe handle - describes objects.
bool | isOpen_
| indicates if the cursor is opened or not (if the stmthpToQuery was located)
string | errorMessage_
| error message returned by the ORACLE DBMS
string | fieldValue_
| temporary variable
Buffers to store data in memory - client side
vector< void * > | buffers_
| buffer to store simple data type (varchar, number, date, etc)
vector< indarray > | ind_
| buffer to store null indicator
SDO_GEOMETRY_TYPE * | global_geom_obj_ [MAX_ROWS]
| buffer to store spatial object
SDO_GEOMETRY_ind * | global_geom_ind_ [MAX_ROWS]
| buffer to store spatial object indicator
vector< unsigned char * > | lobBuffer_
bool | hasBlob_
| vector of buffers to store blob
unsigned long | maxBuflen_
| Flag that indicates if the cursor has blob data type.
int | maxRows_
| Max memory the will be allocated to store blob data.
vector< OCIDefine * > | defines_
| Number of rows to be fetched into memory from database server.
OCIArray * | ordinates_
| store the ordinates to be used in a query (bind)
Information to handle the records or rows stored in memory (buffers)
short | row_Index_
| relative current row index in the memory buffer
int | row_Cur_
| absolute current row index in the memory buffer
int | rows_Fetched_
| number of rows fetched from database
int | rows_Mem_
| number of rows on memory buffer - client side
bool | last_Row_
| if the current row is the last
Information about columns of the record set in memory
int | numColls_
| number of columns
vector< string > | colName_
| name of the columns
vector< int > | colType_
| type of the columns
vector< int > | colSize_
| size of the columns
vector< int > | colScale_
| scale of the columns
vector< string > | colBlobName_
| name of the BLOB columns only

## Detailed Description

A class that implements a concept of record set to a ORACLE DBMS.

This class contains attributes and methods to handle a record set to ORACLE DBMS using OCI (Oracle Call Interface) library.

A record set is generated by a query on the data in the database server. The class OCICursor is used by the drivers TeOCIOracle and TeOCIOracleSpatial that are responsible for the link between ORACLE DBMS and TerraLib.

See also:
  TeOCIConnect

## Constructor & Destructor Documentation

TeOCICursor::TeOCICursor | ( | TeOCIConnection * | conn,
|  | const unsigned long & | maxBlobSize = `0`,
|  | const unsigned long & | maxRowNum = `0`
| ) |  |

Constructor.

TeOCICursor::~TeOCICursor | ( |  | ) | `[inline]`

Destructor.

## Member Function Documentation

bool TeOCICursor::allocateCursor | ( | void |  | ) |

Locates memory to store the record set in the client side.

bool TeOCICursor::appendOrdinates | ( | const double & | val | ) |

Appends the new value to the internal ordinate vector.

bool TeOCICursor::bindOrdinates | ( |  | ) |

Binds the internal ordinate array with the SQL statement.

bool TeOCICursor::checkError | ( | sword | status | ) | `[protected]`

Checks the error associated to error OCI handle.

void TeOCICursor::close | ( | void |  | ) |

Closes the cursor.

string TeOCICursor::colName | ( | int | colnumber | ) |

Returns the column name of a specific column.

int TeOCICursor::colScale | ( | int | colnumber | ) |

Returns the column scale (number of digits after decimal point) of a specific column.

int TeOCICursor::colSize | ( | int | colnumber | ) |

Returns the column size of a specific column.

int TeOCICursor::colType | ( | int | colnumber | ) |

Returns the column type (SQLT) of a specific column.

TeOCIConnection* TeOCICursor::conn | ( |  | ) | `[inline]`

Returns the connection to the database server.

int TeOCICursor::currentRow | ( |  | ) | `[inline]`

Returns the current row index.

void TeOCICursor::defineByPos | ( | int | pos,
|  | void * | value,
|  | int | size,
|  | void * | indicator,
|  | int | type
| ) |  |

Defines the OCI handles by position.

bool TeOCICursor::execute | ( |  | ) |

Executes the SQL statement set previously.

bool TeOCICursor::fetch | ( | int | rows | ) |

Fetchs a number of rows.

void TeOCICursor::freeResult | ( | void |  | ) |

Clears the memory and structures located by the record set.

free the spatial object instance

unsigned int TeOCICursor::getBlobSize | ( | const string & | blobCol | ) |

Returns the size (in unsigend int) of a specific blob column.

bool TeOCICursor::getCoordinates | ( | int | i,
|  | TeCoord2D & | coord
| ) |  |

Gets the i-th coordinate of the SDO_ORDINATES array of the record set current row.

bool TeOCICursor::getCoordinates | ( | vector< TeCoord2D > & | result | ) |

Gets all coordinates of the SDO_ORDINATES array of the record set current row.

int TeOCICursor::getDimArraySize | ( |  | ) |

Gets the size of the SDO_ELEM_INFO array of the record set current row.

bool TeOCICursor::getDimElement | ( | int | i,
|  | int & | elem
| ) |  |

Gets the i-th element of the SDO_ELEM_INFO array of the record set current row.

string TeOCICursor::getErrorMessage | ( |  | ) | `[inline]`

Returns the error message.

char * TeOCICursor::getFieldValue | ( | int | i | ) |

Gets the i-th field value from record set.

int TeOCICursor::getGeometryType | ( |  | ) |

Gets the geometry type of the SDO_GEOMETRY type of the record set current row.

int TeOCICursor::getNumberOrdinates | ( | void |  | ) |

Gets the number of ordinates in the SDO_ORDINATES array of the record set current row.

int TeOCICursor::getSpatialReferenceId | ( |  | ) |

Gets the spatial reference of the SDO_GEOMETRY type of the record set current row.

bool TeOCICursor::getXYZcoord | ( | double & | x,
|  | double & | y
| ) |  |

Gets a coordinate (x and y) of the SDO_POINT type of the record set current row.

bool TeOCICursor::isOpen | ( |  | ) | `[inline]`

Checks if the cursor is opened.

void TeOCICursor::loadCollDescription | ( |  | ) |

Loads all column descriptions (name, type, size and scale)

bool TeOCICursor::moveFirst | ( |  | ) |

Moves to the first row in the record set.

bool TeOCICursor::moveLast | ( |  | ) |

Moves to the last row in the record set.

bool TeOCICursor::moveNext | ( |  | ) |

Moves to the next row in the record set.

bool TeOCICursor::moveTo | ( | int | pos | ) |

Moves to a specific position in the record set.

int TeOCICursor::numCol | ( | void |  | ) |

Returns the columns number in the client side.

int TeOCICursor::numRows | ( | void |  | ) |

Returns the rows number in the client side.

bool TeOCICursor::open | ( |  | ) |

Opens the cursor locating memory and initializing the enviroment.

bool TeOCICursor::prepare | ( | const string & | stmt | ) |

Sets and prepares the SQL statement to be executed.

bool TeOCICursor::query | ( | const string & | query | ) |

Executes a query defined by a SQL statement that returns a record set as result.

bool TeOCICursor::querySDO | ( | const string & | query | ) |

Executes a query defined by a SQL statement that uses SDO_GEOMETRY type and returns a record set as result.

int TeOCICursor::queryType | ( |  | ) |

Returns the query type based on the SQL statement set previously.

bool TeOCICursor::readBlob | ( | double * | buffer,
|  | unsigned int & | bufsize
| ) |  |

Reads a long binary (blob) from database server and returns it as a double vector.

bool TeOCICursor::readBlob | ( | unsigned char * | buffer,
|  | unsigned int & | bufsize,
|  | unsigned int & | blobCol
| ) |  |

Reads a long binary (blob) column (blobCol) from database server and returns it as a unsigned char vector.

bool TeOCICursor::readBlob | ( | unsigned char * | buffer,
|  | unsigned int & | bufsize,
|  | const string & | blobCol
| ) |  |

Reads a long binary (blob) column (blobCol) from database server and returns it as a unsigned char vector.

bool TeOCICursor::readBlob | ( | double ** | buffer | ) |

Gets a pointer to buffer of blob.

## Member Data Documentation

vector<void *> TeOCICursor::buffers_`[protected]`

buffer to store simple data type (varchar, number, date, etc)

vector<string> TeOCICursor::colBlobName_`[protected]`

name of the BLOB columns only

vector<string> TeOCICursor::colName_`[protected]`

name of the columns

vector<int> TeOCICursor::colScale_`[protected]`

scale of the columns

vector<int> TeOCICursor::colSize_`[protected]`

size of the columns

vector<int> TeOCICursor::colType_`[protected]`

type of the columns

TeOCIConnection* TeOCICursor::connection_`[protected]`

A pointer to a opened connection.

vector<OCIDefine *> TeOCICursor::defines_`[protected]`

Number of rows to be fetched into memory from database server.

OCIDefine objects to link buffers in client side and the statement handle

OCIDescribe* TeOCICursor::dschp_`[protected]`

OCI environment describe handle - describes objects.

string TeOCICursor::errorMessage_`[protected]`

error message returned by the ORACLE DBMS

string TeOCICursor::fieldValue_`[protected]`

temporary variable

SDO_GEOMETRY_ind* TeOCICursor::global_geom_ind_[MAX_ROWS]`[protected]`

buffer to store spatial object indicator

SDO_GEOMETRY_TYPE* TeOCICursor::global_geom_obj_[MAX_ROWS]`[protected]`

buffer to store spatial object

bool TeOCICursor::hasBlob_`[protected]`

vector of buffers to store blob

vector<indarray> TeOCICursor::ind_`[protected]`

buffer to store null indicator

bool TeOCICursor::isOpen_`[protected]`

indicates if the cursor is opened or not (if the stmthpToQuery was located)

bool TeOCICursor::last_Row_`[protected]`

if the current row is the last

vector<unsigned char*> TeOCICursor::lobBuffer_`[protected]`

unsigned long TeOCICursor::maxBuflen_`[protected]`

Flag that indicates if the cursor has blob data type.

int TeOCICursor::maxRows_`[protected]`

Max memory the will be allocated to store blob data.

int TeOCICursor::numColls_`[protected]`

number of columns

OCIArray* TeOCICursor::ordinates_`[protected]`

store the ordinates to be used in a query (bind)

int TeOCICursor::row_Cur_`[protected]`

absolute current row index in the memory buffer

short TeOCICursor::row_Index_`[protected]`

relative current row index in the memory buffer

int TeOCICursor::rows_Fetched_`[protected]`

number of rows fetched from database

int TeOCICursor::rows_Mem_`[protected]`

number of rows on memory buffer - client side

OCIStmt* TeOCICursor::stmthpToQuery_`[protected]`

OCI statement handle to query.

The documentation for this class was generated from the following files:

- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Oracle/TeOCICursor.h
- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Oracle/TeOCICursor.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines