Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSqlNullResult Class Reference

#include <qsqlnulldriver_p.h>

+ Inheritance diagram for QSqlNullResult:
+ Collaboration diagram for QSqlNullResult:

Public Member Functions

 QSqlNullResult (const QSqlDriver *d)
 
- Public Member Functions inherited from QSqlResult
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) override
 Returns the data for field index in the current row as a QVariant.
 
bool reset (const QString &) override
 Sets the result to use the SQL statement query for subsequent data retrieval.
 
bool fetch (int) override
 Positions the result to an arbitrary (zero-based) row index.
 
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) 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.
 
void setAt (int) override
 This function is provided for derived classes to set the internal (zero-based) row position to index.
 
void setActive (bool) override
 This function is provided for derived classes to set the internal active state to active.
 
void setLastError (const QSqlError &) override
 This function is provided for derived classes to set the last error to error.
 
void setQuery (const QString &) override
 Sets the current query for the result to query.
 
void setSelect (bool) override
 This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement.
 
void setForwardOnly (bool) override
 Sets forward only mode to forward.
 
bool exec () override
 Executes the query, returning true if successful; otherwise returns false.
 
bool prepare (const QString &) override
 Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly.
 
bool savePrepare (const QString &) override
 Prepares the given query, using the underlying database functionality where possible.
 
void bindValue (int, const QVariant &, QSql::ParamType) override
 Binds the value val of parameter type paramType to position index in the current record (row).
 
void bindValue (const QString &, const QVariant &, QSql::ParamType) override
 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).
 
- Protected Member Functions inherited from QSqlResult
 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 QSqlDriverdriver () const
 Returns the driver associated with the result.
 
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.
 
QVariantListboundValues (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 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 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
 
void setPositionalBindingEnabled (bool enable)
 
bool isPositionalBindingEnabled () const
 
virtual bool nextResult ()
 
void resetBindCount ()
 Resets the number of bind parameters.
 

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
 
- Protected Attributes inherited from QSqlResult
QSqlResultPrivated_ptr
 

Detailed Description

Definition at line 26 of file qsqlnulldriver_p.h.

Constructor & Destructor Documentation

◆ QSqlNullResult()

QSqlNullResult::QSqlNullResult ( const QSqlDriver * d)
inlineexplicit

Definition at line 29 of file qsqlnulldriver_p.h.

References QSqlError::ConnectionError, and QSqlResult::setLastError().

+ Here is the call graph for this function:

Member Function Documentation

◆ bindValue() [1/2]

void QSqlNullResult::bindValue ( const QString & placeholder,
const QVariant & val,
QSql::ParamType paramType )
inlineoverrideprotectedvirtual

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).

Note
Binding an undefined placeholder will result in undefined behavior.
See also
QSqlQuery::bindValue()

Reimplemented from QSqlResult.

Definition at line 53 of file qsqlnulldriver_p.h.

◆ bindValue() [2/2]

void QSqlNullResult::bindValue ( int index,
const QVariant & val,
QSql::ParamType paramType )
inlineoverrideprotectedvirtual

Binds the value val of parameter type paramType to position index in the current record (row).

See also
addBindValue()

Reimplemented from QSqlResult.

Definition at line 52 of file qsqlnulldriver_p.h.

◆ data()

QVariant QSqlNullResult::data ( int index)
inlineoverrideprotectedvirtual

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 33 of file qsqlnulldriver_p.h.

◆ exec()

bool QSqlNullResult::exec ( )
inlineoverrideprotectedvirtual

Executes the query, returning true if successful; otherwise returns false.

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 49 of file qsqlnulldriver_p.h.

◆ fetch()

bool QSqlNullResult::fetch ( int index)
inlineoverrideprotectedvirtual

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.

See also
isActive(), fetchFirst(), fetchLast(), fetchNext(), fetchPrevious()

Implements QSqlResult.

Definition at line 35 of file qsqlnulldriver_p.h.

◆ fetchFirst()

bool QSqlNullResult::fetchFirst ( )
inlineoverrideprotectedvirtual

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.

See also
fetch(), fetchLast()

Implements QSqlResult.

Definition at line 36 of file qsqlnulldriver_p.h.

◆ fetchLast()

bool QSqlNullResult::fetchLast ( )
inlineoverrideprotectedvirtual

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.

See also
fetch(), fetchFirst()

Implements QSqlResult.

Definition at line 37 of file qsqlnulldriver_p.h.

◆ isNull()

bool QSqlNullResult::isNull ( int i)
inlineoverrideprotectedvirtual

Returns true if the field at position index in the current row is null; otherwise returns false.

Implements QSqlResult.

Definition at line 38 of file qsqlnulldriver_p.h.

◆ numRowsAffected()

int QSqlNullResult::numRowsAffected ( )
inlineoverrideprotectedvirtual

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.

See also
size()

Implements QSqlResult.

Definition at line 40 of file qsqlnulldriver_p.h.

◆ prepare()

bool QSqlNullResult::prepare ( const QString & query)
inlineoverrideprotectedvirtual

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.

See also
exec()

Reimplemented from QSqlResult.

Definition at line 50 of file qsqlnulldriver_p.h.

◆ reset()

bool QSqlNullResult::reset ( const QString & query)
inlineoverrideprotectedvirtual

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.

See also
setQuery()

Implements QSqlResult.

Definition at line 34 of file qsqlnulldriver_p.h.

◆ savePrepare()

bool QSqlNullResult::savePrepare ( const QString & query)
inlineoverrideprotectedvirtual

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()".

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 51 of file qsqlnulldriver_p.h.

◆ setActive()

void QSqlNullResult::setActive ( bool active)
inlineoverrideprotectedvirtual

This function is provided for derived classes to set the internal active state to active.

See also
isActive()

Reimplemented from QSqlResult.

Definition at line 43 of file qsqlnulldriver_p.h.

◆ setAt()

void QSqlNullResult::setAt ( int index)
inlineoverrideprotectedvirtual

This function is provided for derived classes to set the internal (zero-based) row position to index.

See also
at()

Reimplemented from QSqlResult.

Definition at line 42 of file qsqlnulldriver_p.h.

◆ setForwardOnly()

void QSqlNullResult::setForwardOnly ( bool forward)
inlineoverrideprotectedvirtual

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.

Note
Calling setForwardOnly after execution of the query will result in unexpected results at best, and crashes at worst.
To make sure the forward-only query completed successfully, the application should check lastError() for an error not only after executing the query, but also after navigating the query results.
Warning
PostgreSQL: While navigating the query results in forward-only mode, do not execute any other SQL command on the same database connection. This will cause the query results to be lost.
See also
isForwardOnly(), fetchNext(), QSqlQuery::setForwardOnly()

Reimplemented from QSqlResult.

Definition at line 47 of file qsqlnulldriver_p.h.

◆ setLastError()

void QSqlNullResult::setLastError ( const QSqlError & error)
inlineoverrideprotectedvirtual

This function is provided for derived classes to set the last error to error.

See also
lastError()

Reimplemented from QSqlResult.

Definition at line 44 of file qsqlnulldriver_p.h.

◆ setQuery()

void QSqlNullResult::setQuery ( const QString & query)
inlineoverrideprotectedvirtual

Sets the current query for the result to query.

You must call reset() to execute the query on the database.

See also
reset(), lastQuery()

Reimplemented from QSqlResult.

Definition at line 45 of file qsqlnulldriver_p.h.

◆ setSelect()

void QSqlNullResult::setSelect ( bool select)
inlineoverrideprotectedvirtual

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.

See also
isSelect()

Reimplemented from QSqlResult.

Definition at line 46 of file qsqlnulldriver_p.h.

◆ size()

int QSqlNullResult::size ( )
inlineoverrideprotectedvirtual

Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement.

See also
numRowsAffected()

Implements QSqlResult.

Definition at line 39 of file qsqlnulldriver_p.h.


The documentation for this class was generated from the following file: