Class CGOdbcStmt
is responsible for work with ODBC's statements, including
work with static read-only cursors. This class supports LOB columns and LOB parameters without limit of the size.
Methods
void prepare(const char *szSQL);
The method prepares specified query to execution. You can bind parameters before
execution. Method can throw exception.
void execute(const char *szSQL);
The method executes specified query. Method can throw exception.
void execute();
The method executes previously prepared query. Prepared query can be executed more than once. Method can throw exception.
void setTimeOut(int iMilSecTimeout);
The method sets timeout for further execute operations. If operation will be longer than specified timeout, statement will be canceled.
void toNative(const char *szSQL, char *szBuff, int lBufMax);
The method translates specified SQL code into native source SQL code. Method can throw exception.
bool moreResults();
The method switches statement to working with results of next operator (if
more than one SQL operators was executed). Method return true if results of
next operator is available and false
in other case.
long getRowCount();
The method returns number of rows affected by previously executed command or
number of rows in cursors (when cursor is already bound). But some data sources can't
return correct value of row count for cursor u,til last
call.
bool bindAuto();
The method binds columns of result cursor. See also default rules of binding. Method can throw exception.
bool bindParamsAuto();
The method binds parameters of previously prepared statement cursor. Only MSSQL server
supports required functionality now to do this method. See also default rules of binding.
Method can throw exception.
void setParamNumber(int lParamCount);
The method specifies number of parameters for manual binding. Each parameter
should be bound only once after call of this method.
void bindParam(int iParam, short iSqlType, short iSqlCType, int iBuffLen, unsigned long iSqlSize, short lPrec);
The method binds parameter manually. See also default rules of binding.
Method can throw exception.
bool cancel();
The method cancels execution of the statement. This method can be called
from other thread. Method can throw exception.
bool first();
The method moves current row to first row of cursor. Method returns true
if
current row is set and false
in case of error.
bool last();
The method moves current row to last row of cursor. Method returns true
if
current row is set and false
in case of error.
bool next();
The method moves current row to next row of cursor. Method returns true
if
current row is set and false
in case of error.
bool prev();
The method moves current row to previous row of cursor. Method returns true
if
current row is set and false
in case of error.
bool go(int iRowNo);
The method moves current row to specified row of cursor. Method returns true
if
current row is set and false
in case of error.
bool skip(int iRowsNumber);
The method skips specified number of rows from current row of cursor. Method returns true
if
current row is set and false
in case of error.
int getRowNo();
The method returns number of current row. Number can have values from 1 to number of rows in cursor.
int getColCount();
The method returns number of columns in cursor.
int findColumn(const char *szName);
The method returns zero-based index of column or -1 if column is not found in cursor.
const CGOdbcStmt::COLUMN *getColumn(int iCol);
The method returns description of the column by zero-based column index.
int getInt(int iCol);
int getInt(const char *szCol);
The method returns integer value of the specified column. The method is applicable
for integer, numeric and character(non-blob) columns. Method can throw exception.
const char *getChar(int iCol);
const char *getChar(const char *szCol);
Method returns string value of the specified column. The method is applicable
for all kinds of columns except SQL_C_BINARY datatypes. For non-character datatypes
internal buffer is used to create string presentation, therefore pointer to
buffer, returned for such kinds of column will be available only to next
call of the method. Method can throw exception.
int getLength(int iCol);
int getLength(const char *szCol);
The method returns actual length of data in specified column. Method can throw exception.
const void *getPtr(int iCol);
const void *getPtr(const char *szCol);
Method return pointer to data in specified column.
bool isNull(int iCol);
bool isNull(const char *szCol);
Method returns true
if columns has null value. Method can throw exception.double getNumber(int iCol);
double getNumber(const char *szCol);
Method returns numeric value of column. Method can throw exception.const CGOdbcStmt::DATE *getDate(int iCol);
const CGOdbcStmt::DATE *getDate(const char *szCol);
Method returns value of date and datetime fields. Method can throw exception.const CGOdbcStmt::TIMESTAMP *getTimeStamp(int iCol);
const CGOdbcStmt::TIMESTAMP *getTimeStamp(const char *szCol);
Method returns value of date and datetime fields. Method can throw exception.const GUID *getGUID(int iCol);
const GUID *getGUID(const char *szCol);
Method returns value of GUID fields. Method can throw exception.void setInt(int iParam, int iValue);
Method should be used to set integer value to numeric parameters. Method can throw exception.void setChar(int iParam, const char *pParam);
Method should be used to set character value to binary or character (including LOB) parameters. Method can throw exception.void setBin(int iParam, const void *pBin, int iLen);
Method should be used to set value to binary (including LOB) parameters. Method can throw exception.void setNumber(int iParam, double dblVal);
Method should be used to set real value to numeric parameters. Method can throw exception.void setDate(int iParam, const CGDateTime::DATE *pDate);
Method should be used to set value to date and datatime parameters. Method can throw exception.void setTimeStamp(int iParam, const CGDateTime::TIMESTAMP *pDate);
Method should be used to set value to date and datatime parameters. Method can throw exception.void setGUID(int iParam, const GUID *);
Method should be used to set value to GUID parameters. Method can throw exception.void setNull(int iParam);
Method should be used to set null value to all kinds of parameters. Method can throw exception.HSTMT getStmt()
Method returns statement handle.