Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtSql.QSqlResult Class Referenceabstract

The QSqlResult class provides an abstract interface for accessing data from specific SQL databases. More...

Inheritance diagram for QtSql.QSqlResult:
Collaboration diagram for QtSql.QSqlResult:

Public Types

enum  BindingSyntax { NamedBinding = 1, PositionalBinding = 0 }
  More...
 
enum  VirtualHookOperation { BatchOperation = 0, DetachFromResultSet = 1, NextResult = 3, SetNumericalPrecision = 2 }
 

Public Member Functions

virtual void CreateProxy ()
 
virtual object Handle ()
 
 
new void Dispose ()
 

Protected Member Functions

 QSqlResult (System.Type dummy)
 
 QSqlResult (QSqlDriver db)
 
 
new void AddBindValue (object val, QSql.ParamTypeFlag type)
 
 
virtual void BindValue (int pos, object val, QSql.ParamTypeFlag type)
 
 
virtual void BindValue (string placeholder, object val, QSql.ParamTypeFlag type)
 
 
new QSql.ParamTypeFlag BindValueType (string placeholder)
 
 
new QSql.ParamTypeFlag BindValueType (int pos)
 
 
new QSqlResult.BindingSyntax bindingSyntax ()
 
 
new object BoundValue (string placeholder)
 
 
new object BoundValue (int pos)
 
 
new int BoundValueCount ()
 
 
new string BoundValueName (int pos)
 
 
new
System.Collections.Generic.List
< System.Object > 
BoundValues ()
 
 
new void Clear ()
 
 
abstract object Data (int i)
 
 
new void DetachFromResultSet ()
 
new QSqlDriver Driver ()
 
 
virtual bool Exec ()
 
 
new bool ExecBatch (bool arrayBind=false)
 
new string ExecutedQuery ()
 
 
abstract bool Fetch (int i)
 
 
abstract bool FetchFirst ()
 
 
abstract bool FetchLast ()
 
 
virtual bool FetchNext ()
 
 
virtual bool FetchPrevious ()
 
 
new bool HasOutValues ()
 
 
new bool IsActive ()
 
 
new bool IsForwardOnly ()
 
 
abstract bool IsNull (int i)
 
 
new bool IsSelect ()
 
 
new bool IsValid ()
 
 
virtual object LastInsertId ()
 
 
new string LastQuery ()
 
 
new bool NextResult ()
 
abstract int NumRowsAffected ()
 
 
virtual bool Prepare (string query)
 
 
virtual QSqlRecord Record ()
 
 
abstract bool Reset (string sqlquery)
 
 
virtual bool SavePrepare (string sqlquery)
 
 
virtual void SetActive (bool a)
 
 
virtual void SetForwardOnly (bool forward)
 
 
virtual void SetQuery (string query)
 
 
virtual void SetSelect (bool s)
 
 
abstract int Size ()
 
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

virtual int At [get, set]
 
 
virtual QSqlError LastError [get, set]
 
 
new QSql.NumericalPrecisionPolicy NumericalPrecisionPolicy [get, set]
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.

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.

See also QSqlDriver.

Member Enumeration Documentation

This enum type specifies the different syntaxes for specifying placeholders in prepared queries.

See also bindingSyntax().

Enumerator:
NamedBinding 

Use the Oracle-style syntax with named placeholders (e.g., ":id")

PositionalBinding 

Use the ODBC-style positional syntax, with "?" as placeholders.

Enumerator:
BatchOperation 
DetachFromResultSet 
NextResult 
SetNumericalPrecision 

Constructor & Destructor Documentation

QtSql.QSqlResult.QSqlResult ( System.Type  dummy)
protected
QtSql.QSqlResult.QSqlResult ( QSqlDriver  db)
protected

Creates a QSqlResult using database driver db. The object is initialized to an inactive state.

See also isActive() and driver().

Member Function Documentation

new void QtSql.QSqlResult.AddBindValue ( object  val,
QSql.ParamTypeFlag  type 
)
protected

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

See also bindValue().

new QSqlResult.BindingSyntax QtSql.QSqlResult.bindingSyntax ( )
protected

Returns the binding syntax used by prepared queries.

virtual void QtSql.QSqlResult.BindValue ( int  pos,
object  val,
QSql.ParamTypeFlag  type 
)
protectedvirtual

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

See also addBindValue().

virtual void QtSql.QSqlResult.BindValue ( string  placeholder,
object  val,
QSql.ParamTypeFlag  type 
)
protectedvirtual

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

See also addBindValue().

new QSql.ParamTypeFlag QtSql.QSqlResult.BindValueType ( string  placeholder)
protected

This is an overloaded function.

Returns the parameter type for the value bound with the given placeholder name.

new QSql.ParamTypeFlag QtSql.QSqlResult.BindValueType ( int  pos)
protected

Returns the parameter type for the value bound at position index.

See also boundValue().

new object QtSql.QSqlResult.BoundValue ( string  placeholder)
protected

This is an overloaded function.

Returns the value bound by the given placeholder name in the current record (row).

See also bindValueType().

new object QtSql.QSqlResult.BoundValue ( int  pos)
protected

Returns the value bound at position index in the current record (row).

See also bindValue() and boundValues().

new int QtSql.QSqlResult.BoundValueCount ( )
protected

Returns the number of bound values in the result.

See also boundValues().

new string QtSql.QSqlResult.BoundValueName ( int  pos)
protected

Returns the name of the bound value at position index in the current record (row).

See also boundValue().

new System.Collections.Generic.List<System.Object> QtSql.QSqlResult.BoundValues ( )
protected

Returns a vector of the result's bound values for the current record (row).

See also boundValueCount().

new void QtSql.QSqlResult.Clear ( )
protected

Clears the entire result set and releases any associated resources.

virtual void QtSql.QSqlResult.CreateProxy ( )
virtual
abstract object QtSql.QSqlResult.Data ( int  i)
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.

new void QtSql.QSqlResult.DetachFromResultSet ( )
protected
new void QtSql.QSqlResult.Dispose ( )
new QSqlDriver QtSql.QSqlResult.Driver ( )
protected

Returns the driver associated with the result. This is the object that was passed to the constructor.

virtual bool QtSql.QSqlResult.Exec ( )
protectedvirtual

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

See also prepare().

new bool QtSql.QSqlResult.ExecBatch ( bool  arrayBind = false)
protected
new string QtSql.QSqlResult.ExecutedQuery ( )
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.

See also exec() and setQuery().

abstract bool QtSql.QSqlResult.Fetch ( int  i)
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.

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

abstract bool QtSql.QSqlResult.FetchFirst ( )
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.

See also fetch() and fetchLast().

abstract bool QtSql.QSqlResult.FetchLast ( )
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.

See also fetch() and fetchFirst().

virtual bool QtSql.QSqlResult.FetchNext ( )
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.

See also fetch() and fetchPrevious().

virtual bool QtSql.QSqlResult.FetchPrevious ( )
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.

virtual object QtSql.QSqlResult.Handle ( )
virtual

Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle.

Warning: Use this with uttermost care and only if you know what you're doing.

Warning: The handle returned here can become a stale pointer if the result is modified (for example, if you clear it).

Warning: The handle can be NULL if the result was not executed yet.

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:

QSqlQuery query = ...

QVariant v = query.result()->handle();

if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) {

// v.data() returns a pointer to the handle

sqlite3_stmt handle = *static_cast<sqlite3_stmt **>(v.data());

if (handle != 0) { // check that it is not NULL

...

}

}

This snippet returns the handle for PostgreSQL or MySQL:

if (v.typeName() == "PGresult") {

PGresult handle = *static_cast<PGresult **>(v.data());

if (handle != 0) ...

}

if (v.typeName() == "MYSQL_STMT") {

MYSQL_STMT *handle = *static_cast<MYSQL_STMT **>(v.data());

if (handle != 0) ...

}

See also QSqlDriver::handle().

new bool QtSql.QSqlResult.HasOutValues ( )
protected

Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise returns false.

See also bindValueType().

new bool QtSql.QSqlResult.IsActive ( )
protected

Returns true if the result has records to be retrieved; otherwise returns false.

new bool QtSql.QSqlResult.IsForwardOnly ( )
protected

Returns true if you can only scroll forward through the result set; otherwise returns false.

See also setForwardOnly().

abstract bool QtSql.QSqlResult.IsNull ( int  i)
protectedpure virtual

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

new bool QtSql.QSqlResult.IsSelect ( )
protected

Returns true if the current result is from a SELECT statement; otherwise returns false.

See also setSelect().

new bool QtSql.QSqlResult.IsValid ( )
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.

See also at().

virtual object QtSql.QSqlResult.LastInsertId ( )
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.

See also QSqlDriver::hasFeature().

new string QtSql.QSqlResult.LastQuery ( )
protected

Returns the current SQL query text, or an empty string if there isn't one.

See also setQuery().

new bool QtSql.QSqlResult.NextResult ( )
protected
abstract int QtSql.QSqlResult.NumRowsAffected ( )
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.

See also size().

virtual bool QtSql.QSqlResult.Prepare ( string  query)
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.

See also exec().

virtual QSqlRecord QtSql.QSqlResult.Record ( )
protectedvirtual

Returns the current record if the query is active; otherwise returns an empty QSqlRecord.

The default implementation always returns an empty QSqlRecord.

See also isActive().

abstract bool QtSql.QSqlResult.Reset ( string  sqlquery)
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.

See also setQuery().

virtual bool QtSql.QSqlResult.SavePrepare ( string  sqlquery)
protectedvirtual

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

virtual void QtSql.QSqlResult.SetActive ( bool  a)
protectedvirtual

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

See also isActive().

virtual void QtSql.QSqlResult.SetForwardOnly ( bool  forward)
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.

Note: Calling setForwardOnly after execution of the query will result in unexpected results at best, and crashes at worst.

See also isForwardOnly(), fetchNext(), and QSqlQuery::setForwardOnly().

virtual void QtSql.QSqlResult.SetQuery ( string  query)
protectedvirtual

Sets the current query for the result to query. You must call reset() to execute the query on the database.

See also reset() and lastQuery().

virtual void QtSql.QSqlResult.SetSelect ( bool  s)
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.

See also isSelect().

abstract int QtSql.QSqlResult.Size ( )
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.

See also numRowsAffected().

Member Data Documentation

SmokeInvocation QtSql.QSqlResult.interceptor
protected

Property Documentation

virtual int QtSql.QSqlResult.At
getsetprotected

Returns the current (zero-based) row position of the result. May return the special values QSql::BeforeFirstRow or QSql::AfterLastRow.

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

virtual QSqlError QtSql.QSqlResult.LastError
getsetprotected

Returns the last error associated with the result.

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

new QSql.NumericalPrecisionPolicy QtSql.QSqlResult.NumericalPrecisionPolicy
getsetprotected
virtual System.IntPtr QtSql.QSqlResult.SmokeObject
getset