Class CGCursor
provides alternative way to
working with cursors (results of "select" SQL operation). Also, cursor
class can be used as simple local storage for structured data.
Methods
CGCursor(CGOdbcStmt *pStmt, const char *szFileName = 0);
CGCursor(const char *szFileName);
CGCursor(int iColumns, CGCursor::COLUMN *pColumns, const char *szFileName = 0);
Constructor creates and initializes cursor object. First variant creates cursor from results
of odbc statement. Second variant opens previously opened
cursor file and last variant creates new unattended cursor.
Parameters
pStmt | Reference to ODBC statement. |
szFileName | Name of the file to create cursor. If file name is omitted, temporary file will be created. |
iColumns | Number of columns |
pColumns | Column's descriptions |
void go(int iRow);
Method loads specified row into internal row buffer. You can access to this buffer
with help of get*/set* methods. Index for row should be greater than zero.
The method can throw cursor exception.
int getRowCount();
Method returns number of rows in cursor object. The method can throw cursor exception.
int getColCount();
Method return number of columns.
const CGCursor::COLUMN *getColumn(int iColumn);
Method returns column description by index of column. Index of column should be zero or greater. The method can throw cursor exception.
int getInt(int iColumn);
int getInt(const char *szName);
Method return integer value of column. This method can be for integer, double and character columns.
The method can throw cursor exception.
const char *getChar(int iColumn);
const char *getChar(const char *szName);
Method returns textual presentation of the field. Method can be used for all
kinds of columns except binaries and blobs. Note that for all datatypes except
string, returned buffer is actual only to next call of this method. The method can throw cursor exception.
double getNumber(int iColumn);
double getNumber(const char *szName);
Method return double value of column. This method can be for integer, double and character columns.
The method can throw cursor exception.
const CGOdbcStmt::DATE *getDate(int iColumn);
const CGOdbcStmt::DATE *getDate(const char *szName);
Method return date value of column. This method can used only for date and timestamp columns.
The method can throw cursor exception.
const CGOdbcStmt::TIMESTAMP *getTimeStamp(int iColumn);
const CGOdbcStmt::TIMESTAMP *getTimeStamp(const char *szName);
Method return date and time value of column. This method can used only timestamp columns.
The method can throw cursor exception.
const void *getPtr(int iColumn);
const void *getPtr(const char *szName);
Method return pointer value of column.
The method can throw cursor exception.
int getLength(int iColumn);
int getLength(const char *szName);
Method returns length in bytes of the value of column.
The method can throw cursor exception.
const GUID * getGUID(int iColumn);
const GUID * getGUID(const char *szName);
Method returns GUID value of the column. This method can be used only
to GUID columns. The method can throw cursor exception.
bool isNull(int iColumn);
bool isNull(const char *szName);
The method returns true if columns has null
value.
All other get* method except getChar
shouldn't
be used when column has null
value. The method can throw cursor exception.
void deleteRow();
The method marks current row as "deleted". The method can throw cursor exception.
bool isDeleted();
The method returns true if current row is marked as "deleted". The method can throw cursor exception.
void update();
The method writes changes in current row to cursor file.
void append();
The method assigns null
value for all columns in current buffer
and switches cursor to "new row" mode. New row will not be visible by all
other methods until update
call. The method can throw cursor exception.
void setInt(int iColumn, int iVal);
void setInt(const char *szName, int iVal);
Method sets new value for numeric columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setChar(int iColumn, const char *);
void setChar(const char *szName, const char *);
Method sets new value for character or CLOB columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setNumber(int iColumn, double dblVal);
void setNumber(const char *szName, double dblVal);
Method sets new value for numeric columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setDate(int iColumn, const CGOdbcStmt::DATE *);
void setDate(const char *szName, const CGOdbcStmt::DATE *);
Method sets new value to date or timestamp columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setTimeStamp(int iColumn, const CGOdbcStmt::TIMESTAMP *);
void setTimeStamp(const char *szName, const CGOdbcStmt::TIMESTAMP *);
Method sets new value to date or timestamp columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setBin(int iColumn, const void *, int);
void setBin(const char *szName, const void *, int);
Method sets new value for binary and blob fields.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setGUID(int iColumn, const GUID * );
void setGUID(const char *szName, const GUID * );
Method sets new value for GUID columns.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.
void setNull(int iColumn);
void setNull(const char *szName);
Method sets null value to specified column.
Data will not be stored in cursor file until update
call. The method can throw cursor exception.