Qt 4.8
Public Functions | Protected Functions | List of all members
QSqlNullResult Class Reference

#include <qsqlnulldriver_p.h>

Inheritance diagram for QSqlNullResult:
QSqlResult

Public Functions

 QSqlNullResult (const QSqlDriver *d)
 
- Public Functions inherited from QSqlResult
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. More...
 
virtual ~QSqlResult ()
 Destroys the object and frees any allocated resources. More...
 

Protected Functions

void bindValue (int, const QVariant &, QSql::ParamType)
 Binds the value val of parameter type paramType to position index in the current record (row). More...
 
void bindValue (const QString &, const QVariant &, QSql::ParamType)
 Binds the value val of parameter type paramType to the placeholder name in the current record (row). More...
 
QVariant data (int)
 Returns the data for field index in the current row as a QVariant. More...
 
bool exec ()
 Executes the query, returning true if successful; otherwise returns false. More...
 
bool fetch (int)
 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 isNull (int)
 Returns true if the field at position index in the current row is null; otherwise returns false. More...
 
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...
 
bool prepare (const QString &)
 Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly. More...
 
bool reset (const QString &)
 Sets the result to use the SQL statement query for subsequent data retrieval. More...
 
bool savePrepare (const QString &)
 Prepares the given query, using the underlying database functionality where possible. More...
 
void setActive (bool)
 This function is provided for derived classes to set the internal active state to active. More...
 
void setAt (int)
 This function is provided for derived classes to set the internal (zero-based) row position to index. More...
 
void setForwardOnly (bool)
 Sets forward only mode to forward. More...
 
void setLastError (const QSqlError &)
 This function is provided for derived classes to set the last error to error. More...
 
void setQuery (const QString &)
 Sets the current query for the result to query. More...
 
void setSelect (bool)
 This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement. 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...
 
- 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...
 
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 QSqlDriverdriver () 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...
 
virtual bool fetchNext ()
 Positions the result to the next available record (row) in the result. More...
 
virtual bool fetchPrevious ()
 Positions the result to the previous record (row) in the result. 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 QSqlRecord record () const
 Returns the current record if the query is active; otherwise returns an empty QSqlRecord. More...
 
void setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy policy)
 
virtual void virtual_hook (int id, void *data)
 

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 }
 

Detailed Description

Definition at line 63 of file qsqlnulldriver_p.h.

Constructors and Destructors

◆ QSqlNullResult()

QSqlNullResult::QSqlNullResult ( const QSqlDriver d)
inlineexplicit

Definition at line 66 of file qsqlnulldriver_p.h.

Referenced by QSqlNullDriver::createResult().

66  : QSqlResult(d)
68  QSqlError(QLatin1String("Driver not loaded"), QLatin1String("Driver not loaded"), QSqlError::ConnectionError)); }
The QSqlError class provides SQL database error information.
Definition: qsqlerror.h:53
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QSqlResult(const QSqlDriver *db)
Creates a QSqlResult using database driver db.
Definition: qsqlresult.cpp:257
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
Definition: qsqlresult.cpp:417

Functions

◆ bindValue() [1/2]

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

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

89 {}

◆ bindValue() [2/2]

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

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Values cannot be bound to multiple locations in the query, eg:

INSERT INTO testtable (id, name, samename) VALUES (:id, :name, :name)

Binding to name will bind to the first :name, but not the second.

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

Reimplemented from QSqlResult.

Definition at line 90 of file qsqlnulldriver_p.h.

90 {}

◆ data()

QVariant QSqlNullResult::data ( int  index)
inlineprotectedvirtual

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

70 { return QVariant(); }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

◆ exec()

bool QSqlNullResult::exec ( )
inlineprotectedvirtual

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

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 86 of file qsqlnulldriver_p.h.

86 { return false; }

◆ fetch()

bool QSqlNullResult::fetch ( int  index)
inlineprotectedvirtual

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

72 { return false; }

◆ fetchFirst()

bool QSqlNullResult::fetchFirst ( )
inlineprotectedvirtual

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

73 { return false; }

◆ fetchLast()

bool QSqlNullResult::fetchLast ( )
inlineprotectedvirtual

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

74 { return false; }

◆ isNull()

bool QSqlNullResult::isNull ( int  i)
inlineprotectedvirtual

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

Implements QSqlResult.

Definition at line 75 of file qsqlnulldriver_p.h.

75 { return false; }

◆ numRowsAffected()

int QSqlNullResult::numRowsAffected ( )
inlineprotectedvirtual

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

77 { return 0; }

◆ prepare()

bool QSqlNullResult::prepare ( const QString query)
inlineprotectedvirtual

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

87 { return false; }

◆ reset()

bool QSqlNullResult::reset ( const QString query)
inlineprotectedvirtual

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

71 { return false; }

◆ savePrepare()

bool QSqlNullResult::savePrepare ( const QString query)
inlineprotectedvirtual

Prepares the given query, using the underlying database functionality where possible.

Returns true if the query is prepared successfully; otherwise returns false.

See also
prepare()

Reimplemented from QSqlResult.

Definition at line 88 of file qsqlnulldriver_p.h.

88 { return false; }

◆ setActive()

void QSqlNullResult::setActive ( bool  active)
inlineprotectedvirtual

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

See also
isActive()

Reimplemented from QSqlResult.

Definition at line 80 of file qsqlnulldriver_p.h.

80 {}

◆ setAt()

void QSqlNullResult::setAt ( int  index)
inlineprotectedvirtual

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

79 {}

◆ setForwardOnly()

void QSqlNullResult::setForwardOnly ( bool  forward)
inlineprotectedvirtual

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.
See also
isForwardOnly(), fetchNext(), QSqlQuery::setForwardOnly()

Reimplemented from QSqlResult.

Definition at line 84 of file qsqlnulldriver_p.h.

84 {}

◆ setLastError()

void QSqlNullResult::setLastError ( const QSqlError error)
inlineprotectedvirtual

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

See also
lastError()

Reimplemented from QSqlResult.

Definition at line 81 of file qsqlnulldriver_p.h.

81 {}

◆ setQuery()

void QSqlNullResult::setQuery ( const QString query)
inlineprotectedvirtual

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

82 {}

◆ setSelect()

void QSqlNullResult::setSelect ( bool  select)
inlineprotectedvirtual

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

83 {}

◆ size()

int QSqlNullResult::size ( )
inlineprotectedvirtual

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

76 { return -1; }

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