![]() |
Qt 6.x
The Qt SDK
|
Public Member Functions | |
QDB2Result (const QDB2Driver *drv) | |
~QDB2Result () | |
bool | prepare (const QString &query) override |
Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly. | |
bool | exec () override |
Executes the query, returning true if successful; otherwise returns false. | |
QVariant | handle () const override |
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle. | |
![]() | |
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 Member Functions | |
QVariant | data (int field) override |
Returns the data for field index in the current row as a QVariant. | |
bool | reset (const QString &query) override |
Sets the result to use the SQL statement query for subsequent data retrieval. | |
bool | fetch (int i) override |
Positions the result to an arbitrary (zero-based) row index. | |
bool | fetchNext () override |
Positions the result to the next available record (row) in the result. | |
bool | fetchFirst () override |
Positions the result to the first record (row 0) in the result. | |
bool | fetchLast () override |
Positions the result to the last record (last row) in the result. | |
bool | isNull (int i) override |
Returns true if the field at position index in the current row is null; otherwise returns false . | |
int | size () override |
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement. | |
int | numRowsAffected () override |
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. | |
QSqlRecord | record () const override |
Returns the current record if the query is active; otherwise returns an empty QSqlRecord. | |
void | virtual_hook (int id, void *data) override |
void | detachFromResultSet () override |
bool | nextResult () override |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
enum | BindingSyntax { PositionalBinding , NamedBinding } |
This enum type specifies the different syntaxes for specifying placeholders in prepared queries. More... | |
enum | VirtualHookOperation |
![]() | |
QSqlResultPrivate * | d_ptr |
Definition at line 58 of file qsql_db2.cpp.
QDB2Result::QDB2Result | ( | const QDB2Driver * | drv | ) |
Definition at line 562 of file qsql_db2.cpp.
QDB2Result::~QDB2Result | ( | ) |
Definition at line 567 of file qsql_db2.cpp.
References d, QString::number(), and qSqlWarning().
|
overrideprotectedvirtual |
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 998 of file qsql_db2.cpp.
References d, QSql::HighPrecision, info, isNull(), QSql::LowPrecisionDouble, QSql::LowPrecisionInt32, QSql::LowPrecisionInt64, QSqlResult::numericalPrecisionPolicy(), qGetBigIntData(), qGetBinaryData(), qGetDoubleData(), qGetIntData(), qGetStringData(), and qWarning.
|
overrideprotectedvirtual |
|
overridevirtual |
Executes the query, returning true if successful; otherwise returns false.
Reimplemented from QSqlResult.
Definition at line 639 of file qsql_db2.cpp.
References QList< T >::append(), QByteArray::at(), ba, QSql::BeforeFirstRow, QSqlResult::bindValueType(), QSqlResult::boundValues(), QString::capacity(), QByteArray::constData(), d, QString::data(), QVarLengthArray< T, Prealloc >::data(), QDateTime::date(), QDate::day(), QString::fromLatin1(), QSqlResult::hasOutValues(), QTime::hour(), i, QSqlResult::isForwardOnly(), QSqlResultPrivate::isVariantNull(), QString::length(), QByteArray::length(), QTime::minute(), QDate::month(), QTime::msec(), QSql::Out, qDB2Warn(), qMakeError(), qMakeFieldInfo(), qMakeStatement(), qParamType, qWarning, QByteArray::resize(), QTime::second(), QSqlResult::setActive(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlResult::setSelect(), QByteArray::size(), QVLABaseBase::size(), QSqlError::StatementError, str, QList< T >::takeFirst(), QDateTime::time(), toLocal8Bit(), QCoreApplication::translate(), QString::utf16(), and QDate::year().
|
overrideprotectedvirtual |
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 891 of file qsql_db2.cpp.
References arg, QSqlResult::at(), QSql::BeforeFirstRow, d, fetchNext(), i, QSqlResult::isForwardOnly(), ok, qMakeError(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlError::StatementError, and QCoreApplication::translate().
Referenced by fetchLast().
|
overrideprotectedvirtual |
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 944 of file qsql_db2.cpp.
References QSqlResult::at(), QSql::BeforeFirstRow, d, fetchNext(), QSqlResult::isForwardOnly(), qMakeError(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlError::StatementError, and QCoreApplication::translate().
|
overrideprotectedvirtual |
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 966 of file qsql_db2.cpp.
References QSql::AfterLastRow, QSqlResult::at(), QSql::BeforeFirstRow, d, fetch(), fetchNext(), i, QSqlResult::isForwardOnly(), and QSqlResult::setAt().
|
overrideprotectedvirtual |
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 926 of file qsql_db2.cpp.
References QSqlResult::at(), d, qMakeError(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlError::StatementError, and QCoreApplication::translate().
Referenced by fetch(), fetchFirst(), and fetchLast().
|
overridevirtual |
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 554 of file qsql_db2.cpp.
References d.
|
overrideprotectedvirtual |
Returns true
if the field at position index in the current row is null; otherwise returns false
.
Implements QSqlResult.
Definition at line 1105 of file qsql_db2.cpp.
Referenced by data().
|
overrideprotectedvirtual |
Reimplemented from QSqlResult.
Definition at line 1141 of file qsql_db2.cpp.
References QSql::BeforeFirstRow, QSqlError::ConnectionError, d, i, qMakeError(), qMakeFieldInfo(), QSqlResult::setActive(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlResult::setSelect(), and QCoreApplication::translate().
|
overrideprotectedvirtual |
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 1116 of file qsql_db2.cpp.
References d, and qSqlWarning().
|
overridevirtual |
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 614 of file qsql_db2.cpp.
References QSql::BeforeFirstRow, d, QSqlResult::isForwardOnly(), qMakeError(), qMakeStatement(), qToTChar(), QSqlResult::setActive(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlError::StatementError, and QCoreApplication::translate().
|
overrideprotectedvirtual |
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 1133 of file qsql_db2.cpp.
References d, and QSqlResult::isActive().
|
overrideprotectedvirtual |
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 577 of file qsql_db2.cpp.
References QSql::BeforeFirstRow, d, i, QSqlResult::isForwardOnly(), qMakeError(), qMakeFieldInfo(), qMakeStatement(), qToTChar(), QSqlResult::setActive(), QSqlResult::setAt(), QSqlResult::setLastError(), QSqlResult::setSelect(), QSqlError::StatementError, and QCoreApplication::translate().
|
overrideprotectedvirtual |
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 1128 of file qsql_db2.cpp.
Reimplemented from QSqlResult.
Definition at line 1172 of file qsql_db2.cpp.
References QSqlResult::virtual_hook().