![]() |
Qt 6.x
The Qt SDK
|
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases. More...
#include <qsqlresult.h>
Public Member Functions | |
virtual | ~QSqlResult () |
Destroys the object and frees any allocated resources. | |
virtual 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. | |
Protected Types | |
enum | BindingSyntax { PositionalBinding , NamedBinding } |
This enum type specifies the different syntaxes for specifying placeholders in prepared queries. More... | |
enum | VirtualHookOperation |
Protected Member Functions | |
QSqlResult (const QSqlDriver *db) | |
Creates a QSqlResult using database driver db. | |
QSqlResult (QSqlResultPrivate &dd) | |
int | at () const |
Returns the current (zero-based) row position of the result. | |
QString | lastQuery () const |
Returns the current SQL query text, or an empty string if there isn't one. | |
QSqlError | lastError () const |
Returns the last error associated with the result. | |
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 . | |
bool | isActive () const |
Returns true if the result has records to be retrieved; otherwise returns false . | |
bool | isSelect () const |
Returns true if the current result is from a SELECT statement; otherwise returns false . | |
bool | isForwardOnly () const |
Returns true if you can only scroll forward through the result set; otherwise returns false . | |
const QSqlDriver * | driver () const |
Returns the driver associated with the result. | |
virtual void | setAt (int at) |
This function is provided for derived classes to set the internal (zero-based) row position to index. | |
virtual void | setActive (bool a) |
This function is provided for derived classes to set the internal active state to active. | |
virtual void | setLastError (const QSqlError &e) |
This function is provided for derived classes to set the last error to error. | |
virtual void | setQuery (const QString &query) |
Sets the current query for the result to query. | |
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. | |
virtual void | setForwardOnly (bool forward) |
Sets forward only mode to forward. | |
virtual bool | exec () |
Executes the query, returning true if successful; otherwise returns false. | |
virtual bool | prepare (const QString &query) |
Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly. | |
virtual bool | savePrepare (const QString &sqlquery) |
Prepares the given query, using the underlying database functionality where possible. | |
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). | |
virtual void | bindValue (const QString &placeholder, const QVariant &val, QSql::ParamType type) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Binds the value val of parameter type paramType to the placeholder name in the current record (row). | |
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). | |
QVariant | boundValue (const QString &placeholder) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value bound by the given placeholder name in the current record (row). | |
QVariant | boundValue (int pos) const |
Returns the value bound at position index in the current record (row). | |
QSql::ParamType | bindValueType (const QString &placeholder) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the parameter type for the value bound with the given placeholder name. | |
QSql::ParamType | bindValueType (int pos) const |
Returns the parameter type for the value bound at position index. | |
int | boundValueCount () const |
Returns the number of bound values in the result. | |
QVariantList & | boundValues (QT6_DECL_NEW_OVERLOAD) |
QVariantList | boundValues (QT6_DECL_NEW_OVERLOAD) const |
QString | executedQuery () const |
Returns the query that was actually executed. | |
QStringList | boundValueNames () const |
Returns the names of all bound values. | |
QString | boundValueName (int pos) const |
Returns the name of the bound value at position index in the current record (row). | |
void | clear () |
Clears the entire result set and releases any associated resources. | |
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 . | |
BindingSyntax | bindingSyntax () const |
Returns the binding syntax used by prepared queries. | |
virtual QVariant | data (int i)=0 |
Returns the data for field index in the current row as a QVariant. | |
virtual bool | isNull (int i)=0 |
Returns true if the field at position index in the current row is null; otherwise returns false . | |
virtual bool | reset (const QString &sqlquery)=0 |
Sets the result to use the SQL statement query for subsequent data retrieval. | |
virtual bool | fetch (int i)=0 |
Positions the result to an arbitrary (zero-based) row index. | |
virtual bool | fetchNext () |
Positions the result to the next available record (row) in the result. | |
virtual bool | fetchPrevious () |
Positions the result to the previous record (row) in the result. | |
virtual bool | fetchFirst ()=0 |
Positions the result to the first record (row 0) in the result. | |
virtual bool | fetchLast ()=0 |
Positions the result to the last record (last row) in the result. | |
virtual int | size ()=0 |
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement. | |
virtual int | numRowsAffected ()=0 |
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. | |
virtual QSqlRecord | record () const |
Returns the current record if the query is active; otherwise returns an empty QSqlRecord. | |
virtual QVariant | lastInsertId () const |
Returns the object ID of the most recent inserted row if the database supports it. | |
virtual void | virtual_hook (int id, void *data) |
virtual bool | execBatch (bool arrayBind=false) |
virtual void | detachFromResultSet () |
virtual void | setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy policy) |
QSql::NumericalPrecisionPolicy | numericalPrecisionPolicy () const |
virtual bool | nextResult () |
void | resetBindCount () |
Resets the number of bind parameters. | |
Protected Attributes | |
QSqlResultPrivate * | d_ptr |
Friends | |
class | QSqlQuery |
class | QSqlTableModelPrivate |
class | ::tst_QSqlQuery |
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
\inmodule QtSql
Normally, you would use QSqlQuery instead of QSqlResult, since QSqlQuery provides a generic wrapper for database-specific implementations of QSqlResult.
If you are implementing your own SQL driver (by subclassing QSqlDriver), you will need to provide your own QSqlResult subclass that implements all the pure virtual functions and other virtual functions that you need.
Definition at line 24 of file qsqlresult.h.
|
protected |
This enum type specifies the different syntaxes for specifying placeholders in prepared queries.
\value PositionalBinding Use the ODBC-style positional syntax, with "?" as placeholders. \value NamedBinding Use the Oracle-style syntax with named placeholders (e.g., ":id")
Enumerator | |
---|---|
PositionalBinding | |
NamedBinding |
Definition at line 37 of file qsqlresult.h.
|
protected |
Definition at line 99 of file qsqlresult.h.
|
virtual |
Destroys the object and frees any allocated resources.
Definition at line 204 of file qsqlresult.cpp.
References d.
|
explicitprotected |
Creates a QSqlResult using database driver db.
The object is initialized to an inactive state.
Definition at line 182 of file qsqlresult.cpp.
References d, d_ptr, db, and setNumericalPrecisionPolicy().
|
protected |
Definition at line 192 of file qsqlresult.cpp.
References d, and setNumericalPrecisionPolicy().
Binds the value val of parameter type paramType to the next available position in the current record (row).
Definition at line 717 of file qsqlresult.cpp.
References bindValue(), d, and PositionalBinding.
Referenced by QSqlQuery::addBindValue().
|
protected |
Returns the current (zero-based) row position of the result.
May return the special values QSql::BeforeFirstRow or QSql::AfterLastRow.
Definition at line 243 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::at(), QPSQLResult::data(), QSqlCachedResult::data(), QDB2Result::fetch(), QMimerSQLResult::fetch(), QMYSQLResult::fetch(), QODBCResult::fetch(), QPSQLResult::fetch(), QSqlCachedResult::fetch(), QDB2Result::fetchFirst(), QMYSQLResult::fetchFirst(), QODBCResult::fetchFirst(), QPSQLResult::fetchFirst(), QSqlCachedResult::fetchFirst(), QDB2Result::fetchLast(), QMYSQLResult::fetchLast(), QODBCResult::fetchLast(), QPSQLResult::fetchLast(), QSqlCachedResult::fetchLast(), fetchNext(), QDB2Result::fetchNext(), QMYSQLResult::fetchNext(), QODBCResult::fetchNext(), QPSQLResult::fetchNext(), QSqlCachedResult::fetchNext(), fetchPrevious(), QODBCResult::fetchPrevious(), QSqlCachedResult::fetchPrevious(), QOCIResult::gotoNext(), QPSQLResult::isNull(), and QSqlCachedResult::isNull().
|
protected |
Returns the binding syntax used by prepared queries.
Definition at line 816 of file qsqlresult.cpp.
References d.
|
protectedvirtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Binds the value val of parameter type paramType to the placeholder name in the current record (row).
Reimplemented in QSqlNullResult.
Definition at line 694 of file qsqlresult.cpp.
References d, QSql::In, and NamedBinding.
|
protectedvirtual |
Binds the value val of parameter type paramType to position index in the current record (row).
Reimplemented in QSqlNullResult.
Definition at line 670 of file qsqlresult.cpp.
References QList< T >::append(), QListSpecialMethodsBase< T >::contains(), d, QSql::In, and PositionalBinding.
Referenced by addBindValue(), QSqlQuery::bindValue(), QSqlQuery::bindValue(), QOCIResultPrivate::bindValues(), QMimerSQLResult::exec(), QSQLiteResult::execBatch(), and execBatch().
|
protected |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the parameter type for the value bound with the given placeholder name.
Definition at line 769 of file qsqlresult.cpp.
Referenced by QDB2Result::exec(), QMimerSQLResult::exec(), QODBCResult::exec(), and QMimerSQLResult::execBatch().
|
protected |
Returns the parameter type for the value bound at position index.
Definition at line 757 of file qsqlresult.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value bound by the given placeholder name in the current record (row).
Definition at line 745 of file qsqlresult.cpp.
References d, and QList< T >::value().
Referenced by QSqlQuery::boundValue(), and QSqlQuery::boundValue().
|
protected |
Returns the value bound at position index in the current record (row).
Definition at line 731 of file qsqlresult.cpp.
References d.
|
protected |
Returns the number of bound values in the result.
Definition at line 780 of file qsqlresult.cpp.
References d.
Referenced by QOCIResult::exec().
|
protected |
Returns the name of the bound value at position index in the current record (row).
Definition at line 875 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::boundValueName().
|
protected |
Returns the names of all bound values.
Definition at line 860 of file qsqlresult.cpp.
Referenced by QSqlQuery::boundValueNames().
|
protected |
Referenced by QSqlQuery::boundValues(), QDB2Result::exec(), QIBaseResult::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QOCIResult::exec(), QODBCResult::exec(), QPSQLResult::exec(), QSQLiteResult::exec(), QMimerSQLResult::execBatch(), and QOCIResult::execBatch().
|
protected |
|
protected |
Clears the entire result set and releases any associated resources.
Definition at line 826 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::exec().
|
protectedpure virtual |
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.
Implemented in QDB2Result, QMYSQLResult, QODBCResult, QMimerSQLResult, QPSQLResult, QSqlCachedResult, XyzResult, and QSqlNullResult.
Referenced by QSqlQuery::value().
|
protectedvirtual |
Reimplemented in QDB2Result, QMYSQLResult, QODBCResult, QSQLiteResult, and QSqlCachedResult.
Definition at line 987 of file qsqlresult.cpp.
Referenced by QSqlQuery::finish().
|
protected |
Returns the driver associated with the result.
This is the object that was passed to the constructor.
Definition at line 329 of file qsqlresult.cpp.
References d.
Referenced by QODBCResult::~QODBCResult(), QMYSQLResult::cleanup(), QMYSQLResult::data(), QSqlQuery::driver(), exec(), QIBaseResult::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QPSQLResult::exec(), QMYSQLResult::fetch(), QODBCResult::fetch(), QMYSQLResult::fetchLast(), QMYSQLResult::fetchNext(), QMYSQLResult::lastInsertId(), QODBCResult::lastInsertId(), QPSQLResult::lastInsertId(), QMYSQLResult::nextResult(), QIBaseResult::prepare(), QMimerSQLResult::prepare(), QSQLiteResult::prepare(), QMYSQLResult::prepare(), QIBaseResult::record(), QMimerSQLResult::record(), QMYSQLResult::record(), QPSQLResult::record(), QMYSQLResult::reset(), QPSQLResult::reset(), savePrepare(), QSqlQuery::size(), and QMYSQLResult::size().
|
protectedvirtual |
Executes the query, returning true if successful; otherwise returns false.
Reimplemented in QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, and QSqlNullResult.
Definition at line 620 of file qsqlresult.cpp.
References d, driver(), QSqlDriver::formatValue(), i, QSqlResultPrivate::isVariantNull(), lastQuery(), QVariant::metaType(), NamedBinding, QString::replace(), ret, setQuery(), and var.
Referenced by QSqlQuery::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QPSQLResult::exec(), and execBatch().
|
protectedvirtual |
Executes a prepared query in batch mode if the driver supports it, otherwise emulates a batch execution using bindValue() and exec(). QSqlDriver::hasFeature() can be used to find out whether a driver supports batch execution.
Batch execution can be faster for large amounts of data since it reduces network roundtrips.
For batch executions, bound values have to be provided as lists of variants (QVariantList).
Each list must contain values of the same type. All lists must contain equal amount of values (rows).
NULL values are passed in as typed QVariants, for example {QVariant(QMetaType::fromType<int>())}
for an integer NULL value.
Example:
Here, we insert two rows into a SQL table, with each row containing three values.
Reimplemented in QSQLiteResult, QMimerSQLResult, and QOCIResult.
Definition at line 966 of file qsqlresult.cpp.
References bindValue(), d, exec(), i, QSql::In, j, and Q_UNUSED.
Referenced by QSqlQuery::execBatch().
|
protected |
Returns the query that was actually executed.
This may differ from the query that was passed, for example if bound values were used with a prepared query and the underlying database doesn't support prepared queries.
Definition at line 840 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::executedQuery().
|
protectedpure virtual |
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.
Implemented in QDB2Result, QMimerSQLResult, QMYSQLResult, QODBCResult, QPSQLResult, QSqlCachedResult, XyzResult, and QSqlNullResult.
Referenced by fetchNext(), fetchPrevious(), and QSqlQuery::seek().
|
protectedpure virtual |
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.
Implemented in QDB2Result, QMimerSQLResult, QMYSQLResult, QODBCResult, QPSQLResult, XyzResult, QSqlCachedResult, and QSqlNullResult.
Referenced by QSqlQuery::first(), and QSqlQuery::next().
|
protectedpure virtual |
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.
Implemented in QDB2Result, QMimerSQLResult, QMYSQLResult, QODBCResult, QPSQLResult, XyzResult, QSqlCachedResult, and QSqlNullResult.
Referenced by QSqlQuery::last(), QSqlQuery::previous(), and QSqlQuery::seek().
|
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 in QDB2Result, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, and QSqlCachedResult.
Definition at line 478 of file qsqlresult.cpp.
Referenced by QSqlQuery::next(), and QSqlQuery::seek().
|
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 in QODBCResult, and QSqlCachedResult.
Definition at line 494 of file qsqlresult.cpp.
Referenced by QSqlQuery::previous(), and QSqlQuery::seek().
|
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 in QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, and QSQLiteResult.
Definition at line 1042 of file qsqlresult.cpp.
|
protected |
Returns true
if at least one of the query's bound values is a QSql::Out
or a QSql::InOut; otherwise returns false
.
Definition at line 887 of file qsqlresult.cpp.
References d, QSql::In, and it.
Referenced by QDB2Result::exec(), QOCIResult::exec(), and QODBCResult::exec().
|
protected |
Returns true
if the result has records to be retrieved; otherwise returns false
.
Definition at line 276 of file qsqlresult.cpp.
References d.
Referenced by QMimerSQLResult::fetch(), QPSQLResult::fetch(), QSqlCachedResult::fetch(), QMimerSQLResult::fetchFirst(), QPSQLResult::fetchFirst(), QMimerSQLResult::fetchLast(), QPSQLResult::fetchLast(), QMimerSQLResult::fetchNext(), QPSQLResult::fetchNext(), QSqlQuery::isActive(), QSqlQuery::isNull(), QMYSQLResult::lastInsertId(), QOCIResult::lastInsertId(), QPSQLResult::lastInsertId(), QSQLiteResult::lastInsertId(), QPSQLResult::nextResult(), QDB2Result::record(), QIBaseResult::record(), QMimerSQLResult::record(), QMYSQLResult::record(), QOCIResult::record(), QODBCResult::record(), QPSQLResult::record(), QSQLiteResult::record(), QMYSQLResult::reset(), QIBaseResult::size(), and QMimerSQLResult::size().
|
protected |
Returns true
if you can only scroll forward through the result set; otherwise returns false
.
Definition at line 505 of file qsqlresult.cpp.
References d.
Referenced by QPSQLResult::data(), QDB2Result::exec(), QPSQLResult::exec(), QDB2Result::fetch(), QMimerSQLResult::fetch(), QMYSQLResult::fetch(), QODBCResult::fetch(), QPSQLResult::fetch(), QDB2Result::fetchFirst(), QMimerSQLResult::fetchFirst(), QMYSQLResult::fetchFirst(), QODBCResult::fetchFirst(), QPSQLResult::fetchFirst(), QDB2Result::fetchLast(), QMimerSQLResult::fetchLast(), QMYSQLResult::fetchLast(), QODBCResult::fetchLast(), QPSQLResult::fetchLast(), QMimerSQLResult::fetchNext(), QOCIResult::fetchNext(), QPSQLResult::fetchNext(), QODBCResult::fetchPrevious(), QSqlCachedResult::init(), QSqlQuery::isForwardOnly(), QPSQLResult::isNull(), QPSQLResult::nextResult(), QDB2Result::prepare(), QMimerSQLResult::prepare(), QODBCResult::prepare(), QPSQLResult::record(), QDB2Result::reset(), QODBCResult::reset(), QPSQLResult::reset(), and QMimerSQLResult::size().
|
protectedpure virtual |
Returns true
if the field at position index in the current row is null; otherwise returns false
.
Implemented in QMYSQLResult, QODBCResult, QPSQLResult, QDB2Result, QSqlCachedResult, QMimerSQLResult, XyzResult, and QSqlNullResult.
Referenced by QSqlQuery::isNull().
|
protected |
Returns true
if the current result is from a SELECT
statement; otherwise returns false
.
Definition at line 318 of file qsqlresult.cpp.
References d.
Referenced by QMYSQLResult::data(), QIBaseResult::exec(), QMYSQLResult::exec(), QODBCResult::exec(), QMimerSQLResult::fetch(), QMimerSQLResult::fetchFirst(), QMimerSQLResult::fetchLast(), QMimerSQLResult::fetchNext(), QSqlQuery::isSelect(), QMYSQLResult::nextResult(), QIBaseResult::prepare(), QMimerSQLResult::record(), QMYSQLResult::record(), QOCIResult::record(), QODBCResult::record(), QPSQLResult::record(), QSQLiteResult::record(), QMYSQLResult::reset(), QIBaseResult::size(), QMimerSQLResult::size(), and QMYSQLResult::size().
|
protected |
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
.
Definition at line 258 of file qsqlresult.cpp.
References QSql::AfterLastRow, QSql::BeforeFirstRow, and d.
Referenced by QSQLiteResult::exec(), QSqlQuery::isNull(), and QSqlQuery::isValid().
|
protected |
Returns the last error associated with the result.
Definition at line 370 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::exec(), QSQLiteResult::exec(), QOCIResult::execBatch(), and QSqlQuery::lastError().
|
protectedvirtual |
Returns the object ID of the most recent inserted row if the database supports it.
An invalid QVariant will be returned if the query did not insert any value or if the database does not report the id back. If more than one row was touched by the insert, the behavior is undefined.
Note that for Oracle databases the row's ROWID will be returned, while for MySQL databases the row's auto-increment field will be returned.
Reimplemented in QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, and QSQLiteResult.
Definition at line 927 of file qsqlresult.cpp.
Referenced by QSqlQuery::lastInsertId().
|
protected |
Returns the current SQL query text, or an empty string if there isn't one.
Definition at line 230 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::exec(), exec(), QOCIResult::exec(), QSqlQuery::exec(), QOCIResult::gotoNext(), and QSqlQuery::lastQuery().
|
protectedvirtual |
Reimplemented in QDB2Result, QMYSQLResult, QODBCResult, and QPSQLResult.
Definition at line 1009 of file qsqlresult.cpp.
Referenced by QSqlQuery::nextResult().
|
protected |
Definition at line 1001 of file qsqlresult.cpp.
References d.
Referenced by QDB2Result::data(), QMYSQLResult::data(), QODBCResult::data(), QMimerSQLResult::data(), QPSQLResult::data(), QSqlQuery::exec(), QIBaseResult::gotoNext(), QSqlQuery::numericalPrecisionPolicy(), and QSqlQuery::prepare().
|
protectedpure virtual |
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.
Implemented in QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, XyzResult, and QSqlNullResult.
Referenced by QSqlQuery::exec(), QSqlQuery::exec(), and QSqlQuery::numRowsAffected().
|
protectedvirtual |
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 in QSqlNullResult, QDB2Result, QIBaseResult, QMimerSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, and QMYSQLResult.
Definition at line 576 of file qsqlresult.cpp.
References d.
Referenced by QMimerSQLResult::prepare(), QOCIResult::prepare(), QPSQLResult::prepare(), QMYSQLResult::prepare(), and savePrepare().
|
protectedvirtual |
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
The default implementation always returns an empty QSqlRecord.
Reimplemented in QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, and XyzResult.
Definition at line 908 of file qsqlresult.cpp.
Referenced by QSqlQuery::isNull(), QSqlQuery::record(), and QSqlQuery::value().
|
protectedpure virtual |
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.
Implemented in XyzResult, QSqlNullResult, QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, and QSQLiteResult.
Referenced by QSqlQuery::exec().
|
protected |
Resets the number of bind parameters.
Definition at line 849 of file qsqlresult.cpp.
References d.
Referenced by QSqlQuery::exec(), QSqlQuery::execBatch(), and QOCIResult::execBatch().
|
protectedvirtual |
Prepares the given query, using the underlying database functionality where possible.
Returns true
if the query is prepared successfully; otherwise returns false
.
Note: This method should have been called "safePrepare()".
Reimplemented in QSqlNullResult.
Definition at line 550 of file qsqlresult.cpp.
References d, driver(), hasFeature(), QSqlDriver::NamedPlaceholders, prepare(), and QSqlDriver::PreparedQueries.
Referenced by QSqlQuery::prepare().
|
protectedvirtual |
This function is provided for derived classes to set the internal active state to active.
Reimplemented in QSqlNullResult.
Definition at line 343 of file qsqlresult.cpp.
References d.
Referenced by QMYSQLResult::cleanup(), QPSQLResult::cleanup(), QSqlCachedResult::cleanup(), QDB2Result::exec(), QIBaseResult::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QOCIResult::exec(), QODBCResult::exec(), QSQLiteResult::exec(), QSqlQuery::exec(), QSqlQuery::finish(), QDB2Result::nextResult(), QMYSQLResult::nextResult(), QODBCResult::nextResult(), QSqlQuery::prepare(), QDB2Result::prepare(), QIBaseResult::prepare(), QODBCResult::prepare(), QDB2Result::reset(), QMYSQLResult::reset(), and QODBCResult::reset().
|
protectedvirtual |
This function is provided for derived classes to set the internal (zero-based) row position to index.
Reimplemented in QSqlNullResult.
Definition at line 289 of file qsqlresult.cpp.
References d.
Referenced by QMYSQLResult::cleanup(), QPSQLResult::cleanup(), QSqlCachedResult::cleanup(), QSqlCachedResult::clearValues(), QDB2Result::exec(), QIBaseResult::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QOCIResult::exec(), QODBCResult::exec(), QSqlQuery::exec(), QDB2Result::fetch(), QMimerSQLResult::fetch(), QMYSQLResult::fetch(), QODBCResult::fetch(), QPSQLResult::fetch(), QSqlCachedResult::fetch(), QDB2Result::fetchFirst(), QMimerSQLResult::fetchFirst(), QODBCResult::fetchFirst(), QPSQLResult::fetchFirst(), QSqlCachedResult::fetchFirst(), QDB2Result::fetchLast(), QMimerSQLResult::fetchLast(), QODBCResult::fetchLast(), QPSQLResult::fetchLast(), QSqlCachedResult::fetchLast(), QDB2Result::fetchNext(), QMimerSQLResult::fetchNext(), QMYSQLResult::fetchNext(), QODBCResult::fetchNext(), QPSQLResult::fetchNext(), QSqlCachedResult::fetchNext(), QODBCResult::fetchPrevious(), QSqlQuery::finish(), QIBaseResult::gotoNext(), QOCIResult::gotoNext(), QSqlQuery::next(), QDB2Result::nextResult(), QMYSQLResult::nextResult(), QODBCResult::nextResult(), QPSQLResult::nextResult(), QSqlQuery::prepare(), QDB2Result::prepare(), QIBaseResult::prepare(), QODBCResult::prepare(), QSqlQuery::previous(), QDB2Result::reset(), QMYSQLResult::reset(), QODBCResult::reset(), and QSqlQuery::seek().
|
protectedvirtual |
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 in QSqlNullResult.
Definition at line 535 of file qsqlresult.cpp.
References d.
Referenced by QODBCResult::exec(), QPSQLResult::exec(), QODBCResult::reset(), QPSQLResult::reset(), and QSqlQuery::setForwardOnly().
This function is provided for derived classes to set the last error to error.
Reimplemented in QSqlNullResult.
Definition at line 359 of file qsqlresult.cpp.
Referenced by QSqlNullResult::QSqlNullResult(), QMimerSQLResult::data(), QSqlQuery::exec(), QDB2Result::exec(), QIBaseResult::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QOCIResult::exec(), QODBCResult::exec(), QPSQLResult::exec(), QSQLiteResult::exec(), QSqlQuery::exec(), QMimerSQLResult::execBatch(), QDB2Result::fetch(), QMimerSQLResult::fetch(), QMYSQLResult::fetch(), QODBCResult::fetch(), QDB2Result::fetchFirst(), QMimerSQLResult::fetchFirst(), QODBCResult::fetchFirst(), QMimerSQLResult::fetchLast(), QODBCResult::fetchLast(), QDB2Result::fetchNext(), QMimerSQLResult::fetchNext(), QMYSQLResult::fetchNext(), QODBCResult::fetchNext(), QPSQLResult::fetchNext(), QODBCResult::fetchPrevious(), QSqlQuery::finish(), QOCIResult::gotoNext(), QMimerSQLResult::isNull(), QDB2Result::nextResult(), QMYSQLResult::nextResult(), QODBCResult::nextResult(), QSqlQuery::prepare(), QDB2Result::prepare(), QMimerSQLResult::prepare(), QOCIResult::prepare(), QODBCResult::prepare(), QPSQLResult::prepare(), QSQLiteResult::prepare(), QMYSQLResult::prepare(), QDB2Result::reset(), QMYSQLResult::reset(), QODBCResult::reset(), and QPSQLResult::reset().
|
protectedvirtual |
Reimplemented in QSqlCachedResult.
Definition at line 993 of file qsqlresult.cpp.
Referenced by QSqlResult(), QSqlResult(), QSqlQuery::exec(), QSqlQuery::prepare(), QSqlCachedResult::setNumericalPrecisionPolicy(), and QSqlQuery::setNumericalPrecisionPolicy().
Sets the current query for the result to query.
You must call reset() to execute the query on the database.
Reimplemented in QSqlNullResult.
Definition at line 217 of file qsqlresult.cpp.
References d.
Referenced by exec(), and QSqlQuery::exec().
|
protectedvirtual |
This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT
statement.
The select parameter should be true if the statement is a SELECT
statement; otherwise it should be false.
Reimplemented in QSqlNullResult.
Definition at line 305 of file qsqlresult.cpp.
Referenced by QDB2Result::exec(), QMimerSQLResult::exec(), QMYSQLResult::exec(), QOCIResult::exec(), QODBCResult::exec(), QSQLiteResult::exec(), QDB2Result::nextResult(), QMYSQLResult::nextResult(), QODBCResult::nextResult(), QIBaseResult::prepare(), QSQLiteResult::prepare(), QMYSQLResult::prepare(), QDB2Result::reset(), QMYSQLResult::reset(), and QODBCResult::reset().
|
protectedpure virtual |
Returns the size of the SELECT
result, or -1 if it cannot be determined or if the query is not a SELECT
statement.
Implemented in QDB2Result, QIBaseResult, QMimerSQLResult, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, XyzResult, and QSqlNullResult.
Referenced by QSqlQuery::exec(), QSqlQuery::exec(), and QSqlQuery::size().
Reimplemented in QDB2Result, QMYSQLResult, QOCIResult, QODBCResult, QPSQLResult, QSQLiteResult, and QSqlCachedResult.
Definition at line 934 of file qsqlresult.cpp.
Referenced by QDB2Result::virtual_hook(), QMYSQLResult::virtual_hook(), QODBCResult::virtual_hook(), QPSQLResult::virtual_hook(), and QSqlCachedResult::virtual_hook().
|
friend |
Definition at line 30 of file qsqlresult.h.
|
friend |
Definition at line 27 of file qsqlresult.h.
|
friend |
Definition at line 28 of file qsqlresult.h.
|
protected |
Definition at line 108 of file qsqlresult.h.
Referenced by QSqlResult().