Qt 4.8
|
#include <qsql_odbc.h>
Public Functions | |
bool | exec () |
Executes the query, returning true if successful; otherwise returns false. More... | |
QVariant | handle () const |
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle. More... | |
bool | prepare (const QString &query) |
Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly. More... | |
QODBCResult (const QODBCDriver *db, QODBCDriverPrivate *p) | |
virtual void | setForwardOnly (bool forward) |
Sets forward only mode to forward. More... | |
virtual | ~QODBCResult () |
Public Functions inherited from QSqlResult | |
virtual | ~QSqlResult () |
Destroys the object and frees any allocated resources. More... | |
Protected Functions | |
QVariant | data (int field) |
Returns the data for field index in the current row as a QVariant. More... | |
bool | fetch (int i) |
Positions the result to an arbitrary (zero-based) row index. More... | |
bool | fetchFirst () |
Positions the result to the first record (row 0) in the result. More... | |
bool | fetchLast () |
Positions the result to the last record (last row) in the result. More... | |
bool | fetchNext () |
Positions the result to the next available record (row) in the result. More... | |
bool | fetchPrevious () |
Positions the result to the previous record (row) in the result. More... | |
bool | isNull (int field) |
Returns true if the field at position index in the current row is null; otherwise returns false. More... | |
bool | nextResult () |
int | numRowsAffected () |
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or if the query is a SELECT statement. More... | |
QSqlRecord | record () const |
Returns the current record if the query is active; otherwise returns an empty QSqlRecord. More... | |
bool | reset (const QString &query) |
Sets the result to use the SQL statement query for subsequent data retrieval. More... | |
int | size () |
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement. More... | |
void | virtual_hook (int id, void *data) |
Protected Functions inherited from QSqlResult | |
void | addBindValue (const QVariant &val, QSql::ParamType type) |
Binds the value val of parameter type paramType to the next available position in the current record (row). More... | |
int | at () const |
Returns the current (zero-based) row position of the result. More... | |
BindingSyntax | bindingSyntax () const |
Returns the binding syntax used by prepared queries. More... | |
virtual void | bindValue (int pos, const QVariant &val, QSql::ParamType type) |
Binds the value val of parameter type paramType to position index in the current record (row). More... | |
virtual void | bindValue (const QString &placeholder, const QVariant &val, QSql::ParamType type) |
Binds the value val of parameter type paramType to the placeholder name in the current record (row). More... | |
QSql::ParamType | bindValueType (const QString &placeholder) const |
Returns the parameter type for the value bound with the given placeholder name. More... | |
QSql::ParamType | bindValueType (int pos) const |
Returns the parameter type for the value bound at position index. More... | |
QVariant | boundValue (const QString &placeholder) const |
Returns the value bound by the given placeholder name in the current record (row). More... | |
QVariant | boundValue (int pos) const |
Returns the value bound at position index in the current record (row). More... | |
int | boundValueCount () const |
Returns the number of bound values in the result. More... | |
QString | boundValueName (int pos) const |
Returns the name of the bound value at position index in the current record (row). More... | |
QVector< QVariant > & | boundValues () const |
Returns a vector of the result's bound values for the current record (row). More... | |
void | clear () |
Clears the entire result set and releases any associated resources. More... | |
void | detachFromResultSet () |
const QSqlDriver * | driver () const |
Returns the driver associated with the result. More... | |
bool | execBatch (bool arrayBind=false) |
Executes a prepared query in batch mode if the driver supports it, otherwise emulates a batch execution using bindValue() and exec(). More... | |
QString | executedQuery () const |
Returns the query that was actually executed. More... | |
bool | hasOutValues () const |
Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise returns false. More... | |
bool | isActive () const |
Returns true if the result has records to be retrieved; otherwise returns false. More... | |
bool | isForwardOnly () const |
Returns true if you can only scroll forward through the result set; otherwise returns false. More... | |
bool | isSelect () const |
Returns true if the current result is from a SELECT statement; otherwise returns false. More... | |
bool | isValid () const |
Returns true if the result is positioned on a valid record (that is, the result is not positioned before the first or after the last record); otherwise returns false. More... | |
QSqlError | lastError () const |
Returns the last error associated with the result. More... | |
virtual QVariant | lastInsertId () const |
Returns the object ID of the most recent inserted row if the database supports it. More... | |
QString | lastQuery () const |
Returns the current SQL query text, or an empty string if there isn't one. More... | |
bool | nextResult () |
QSql::NumericalPrecisionPolicy | numericalPrecisionPolicy () const |
QSqlResult (const QSqlDriver *db) | |
Creates a QSqlResult using database driver db. More... | |
virtual bool | savePrepare (const QString &sqlquery) |
Prepares the given query, using the underlying database functionality where possible. More... | |
virtual void | setActive (bool a) |
This function is provided for derived classes to set the internal active state to active. More... | |
virtual void | setAt (int at) |
This function is provided for derived classes to set the internal (zero-based) row position to index. More... | |
virtual void | setLastError (const QSqlError &e) |
This function is provided for derived classes to set the last error to error. More... | |
void | setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy policy) |
virtual void | setQuery (const QString &query) |
Sets the current query for the result to query. More... | |
virtual void | setSelect (bool s) |
This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement. More... | |
Properties | |
QODBCPrivate * | d |
Additional Inherited Members | |
Protected Types inherited from QSqlResult | |
enum | BindingSyntax { PositionalBinding, NamedBinding } |
This enum type specifies the different syntaxes for specifying placeholders in prepared queries. More... | |
enum | VirtualHookOperation { BatchOperation, DetachFromResultSet, SetNumericalPrecision, NextResult } |
Definition at line 82 of file qsql_odbc.h.
QODBCResult::QODBCResult | ( | const QODBCDriver * | db, |
QODBCDriverPrivate * | p | ||
) |
Definition at line 889 of file qsql_odbc.cpp.
|
virtual |
Definition at line 895 of file qsql_odbc.cpp.
|
protectedvirtual |
Returns the data for field index in the current row as a QVariant.
This function is only called if the result is in an active state and is positioned on a valid record and index is non-negative. Derived classes must reimplement this function and return the value of field index, or QVariant() if it cannot be determined.
Implements QSqlResult.
Definition at line 1128 of file qsql_odbc.cpp.
Referenced by isNull(), prepare(), reset(), and virtual_hook().
|
virtual |
Executes the query, returning true if successful; otherwise returns false.
Reimplemented from QSqlResult.
Definition at line 1318 of file qsql_odbc.cpp.
|
protectedvirtual |
Positions the result to an arbitrary (zero-based) row index.
This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the row index, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.
Implements QSqlResult.
Definition at line 990 of file qsql_odbc.cpp.
|
protectedvirtual |
Positions the result to the first record (row 0) in the result.
This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the first record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.
Implements QSqlResult.
Definition at line 1048 of file qsql_odbc.cpp.
|
protectedvirtual |
Positions the result to the last record (last row) in the result.
This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the last record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.
Implements QSqlResult.
Definition at line 1089 of file qsql_odbc.cpp.
|
protectedvirtual |
Positions the result to the next available record (row) in the result.
This function is only called if the result is in an active state. The default implementation calls fetch() with the next index. Derived classes can reimplement this function and position the result to the next record in some other way, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.
Reimplemented from QSqlResult.
Definition at line 1026 of file qsql_odbc.cpp.
Referenced by fetch(), fetchFirst(), and fetchLast().
|
protectedvirtual |
Positions the result to the previous record (row) in the result.
This function is only called if the result is in an active state. The default implementation calls fetch() with the previous index. Derived classes can reimplement this function and position the result to the next record in some other way, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.
Reimplemented from QSqlResult.
Definition at line 1070 of file qsql_odbc.cpp.
|
virtual |
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle.
The handle returned here is database-dependent, you should query the type name of the variant before accessing it.
This example retrieves the handle for a sqlite result:
This snippet returns the handle for PostgreSQL or MySQL:
Reimplemented from QSqlResult.
Definition at line 1674 of file qsql_odbc.cpp.
|
protectedvirtual |
Returns true if the field at position index in the current row is null; otherwise returns false.
Implements QSqlResult.
Definition at line 1228 of file qsql_odbc.cpp.
|
protected |
Definition at line 1679 of file qsql_odbc.cpp.
Referenced by virtual_hook().
|
protectedvirtual |
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or if the query is a SELECT
statement.
Implements QSqlResult.
Definition at line 1246 of file qsql_odbc.cpp.
|
virtual |
Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly.
Returns true if the query is prepared successfully; otherwise returns false.
Reimplemented from QSqlResult.
Definition at line 1257 of file qsql_odbc.cpp.
|
protectedvirtual |
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
The default implementation always returns an empty QSqlRecord.
Reimplemented from QSqlResult.
Definition at line 1667 of file qsql_odbc.cpp.
|
protectedvirtual |
Sets the result to use the SQL statement query for subsequent data retrieval.
Derived classes must reimplement this function and apply the query to the database. This function is only called after the result is set to an inactive state and is positioned before the first record of the new result. Derived classes should return true if the query was successful and ready to be used, or false otherwise.
Implements QSqlResult.
Definition at line 907 of file qsql_odbc.cpp.
|
virtual |
Sets forward only mode to forward.
If forward is true, only fetchNext() is allowed for navigating the results. Forward only mode needs much less memory since results do not have to be cached. By default, this feature is disabled.
Setting forward only to false is a suggestion to the database engine, which has the final say on whether a result set is forward only or scrollable. isForwardOnly() will always return the correct status of the result set.
Reimplemented from QSqlResult.
Definition at line 1734 of file qsql_odbc.cpp.
|
protectedvirtual |
Returns the size of the SELECT
result, or -1 if it cannot be determined or if the query is not a SELECT
statement.
Implements QSqlResult.
Definition at line 1241 of file qsql_odbc.cpp.
|
protectedvirtual |
Reimplemented from QSqlResult.
Definition at line 1718 of file qsql_odbc.cpp.
|
private |
Definition at line 110 of file qsql_odbc.h.
Referenced by data(), exec(), fetch(), fetchFirst(), fetchLast(), fetchNext(), fetchPrevious(), handle(), isNull(), nextResult(), numRowsAffected(), prepare(), QODBCResult(), record(), reset(), setForwardOnly(), virtual_hook(), and ~QODBCResult().