#include <dbquery.h>
Public Types | |
enum | QueryState { Q_CREATED, Q_PREPARED, Q_EXECUTED, Q_CURSOR_OPEN, Q_FINISHED } |
Public Methods | |
DbQuery (const LookString &theQueryText="", DbConnection *theConnection=NULL) | |
Constructor. More... | |
virtual | ~DbQuery () |
Destructor. | |
bool | Prepare (void) |
Prepare. More... | |
bool | Describe (void) |
Describe. Prepare calls this for you. More... | |
bool | Execute (void) |
Execute. More... | |
long | ColumnCount (void) const |
How many columns are in our query? More... | |
long | RowCount (bool countNow=false) |
How many rows are in the result set. More... | |
LookString | GetColumnName (long theColumnNo) |
Get the name of a column. More... | |
bool | GetColumnNullable (long theColumnNo) |
Is the column nullable? More... | |
long | GetColumnTypeID (long theColumnNo) |
What type will the data in the column be? More... | |
DbRow* | Fetch () |
Fetch the next row. More... | |
DbRow* | GetRow (long theRowNumber) |
Get row from cache. More... | |
void | Close (void) |
Close our cursor. | |
void | AddParameter (LookTypeBase *theParameter, bool isLong=false) |
Add a parameter. More... | |
void | ClearParameters (void) |
Clear out all the parameters added so far. | |
void | UseRowCache (void) |
int | GetNRowsAffected (void) |
Protected Methods | |
void | UploadParameters (void) |
Upload parameters (called by Execute()). | |
void | TidyCursor (void) |
bool | IsPrepared (void) const |
bool | IsExecuted (void) const |
bool | CursorIsOpen (void) const |
Protected Attributes | |
DbConnection* | itsConnection |
bool | itOwnsConnection |
LookString | itsQueryText |
QueryState | itsState |
long | itsCurrentRowNumber |
long | itsRowCount |
bool | itHasRowCache |
DbRow* | itsLastFetchedRow |
DbRowPtrList | itsRows |
LookTypePtrList | itsParameters |
long | itsLongParameterIndex |
LOOK_STMT | itsStmt |
int | itsRowsAffected |
Static Protected Attributes | |
long | itsNextStatementId |
A DbQuery is associated with a SQL Statement.
At the very least you need to Prepare() and Execute() it.
You may need to Fetch() rows.
Parameters can be used in the SQL statement - these must be marked with ? (eg "select * from columns where name = ?").
You must delete all queries on a connection before the connection.
The global connection must have been set before using this class (DbConnection::SetGlobalConnection()).
|
Constructor. If the connection is DbConnection::PERSISTENT_READ_ONLY a new connection is made just for this query.
|
|
Add a parameter. isLong is required for at least odbc and oci - long (as in database LONG, not integer long) parameters are treated slightly differently.
|
|
How many columns are in our query? The query must have been Prepare()d and probably ought to have results (!). Eg "SELECT * FROM DUAL" on oracle will give 1.
|
|
Describe. Prepare calls this for you. This shouldn't really be public - to describe a SQL Statement you ought to call Prepare().
|
|
Execute. Actually execute the statement. If successful, the query state will be Q_CURSOR_OPEN if there are results to be returned, or Q_EXECUTED if none. Any rows in the row cache will be cleared.
|
|
Fetch the next row. If there are no more rows to fetch, this returns 0 (null). |
|
Get the name of a column. Prepare() must have been called.
|
|
Is the column nullable? Prepare() must have been called.
|
|
What type will the data in the column be? Prepare() must have been called.
|
|
Get row from cache. Get theRowNumberth row from the row cache. If necessary, fetches are done to get the rows before. If there are insufficient rows, return 0. The query must have been Execute()d and must have a row cache.
|
|
Prepare. You need to call this before Execute().
|
|
How many rows are in the result set. The query must have been Prepare()d (and Execute()d?).
|