'\" t .TH TQSqlResult 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*- .\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the .\" license file included in the distribution for a complete license .\" statement. .\" .ad l .nh .SH NAME TQSqlResult \- Abstract interface for accessing data from SQL databases .SH SYNOPSIS \fC#include \fR .PP .SS "Public Members" .in +1c .ti -1c .BI "virtual \fB~TQSqlResult\fR ()" .br .in -1c .SS "Protected Members" .in +1c .ti -1c .BI "\fBTQSqlResult\fR ( const TQSqlDriver * db )" .br .ti -1c .BI "int \fBat\fR () const" .br .ti -1c .BI "TQString \fBlastQuery\fR () const" .br .ti -1c .BI "TQSqlError \fBlastError\fR () const" .br .ti -1c .BI "bool \fBisValid\fR () const" .br .ti -1c .BI "bool \fBisActive\fR () const" .br .ti -1c .BI "bool \fBisSelect\fR () const" .br .ti -1c .BI "bool \fBisForwardOnly\fR () const" .br .ti -1c .BI "const TQSqlDriver * \fBdriver\fR () const" .br .ti -1c .BI "virtual void \fBsetAt\fR ( int at )" .br .ti -1c .BI "virtual void \fBsetActive\fR ( bool a )" .br .ti -1c .BI "virtual void \fBsetLastError\fR ( const TQSqlError & e )" .br .ti -1c .BI "virtual void \fBsetQuery\fR ( const TQString & query )" .br .ti -1c .BI "virtual void \fBsetSelect\fR ( bool s )" .br .ti -1c .BI "virtual void \fBsetForwardOnly\fR ( bool forward )" .br .ti -1c .BI "virtual TQVariant \fBdata\fR ( int i ) = 0" .br .ti -1c .BI "virtual bool \fBisNull\fR ( int i ) = 0" .br .ti -1c .BI "virtual bool \fBreset\fR ( const TQString & query ) = 0" .br .ti -1c .BI "virtual bool \fBfetch\fR ( int i ) = 0" .br .ti -1c .BI "virtual bool \fBfetchNext\fR ()" .br .ti -1c .BI "virtual bool \fBfetchPrev\fR ()" .br .ti -1c .BI "virtual bool \fBfetchFirst\fR () = 0" .br .ti -1c .BI "virtual bool \fBfetchLast\fR () = 0" .br .ti -1c .BI "virtual int \fBsize\fR () = 0" .br .ti -1c .BI "virtual int \fBnumRowsAffected\fR () = 0" .br .in -1c .SH DESCRIPTION The TQSqlResult class provides an abstract interface for accessing data from SQL databases. .PP Normally you would use TQSqlQuery instead of TQSqlResult since TQSqlQuery provides a generic wrapper for database-specific implementations of TQSqlResult. .PP See also TQSql and Database Classes. .SH MEMBER FUNCTION DOCUMENTATION .SH "TQSqlResult::TQSqlResult ( const TQSqlDriver * db )\fC [protected]\fR" Protected constructor which creates a TQSqlResult using database \fIdb\fR. The object is initialized to an inactive state. .SH "TQSqlResult::~TQSqlResult ()\fC [virtual]\fR" Destroys the object and frees any allocated resources. .SH "int TQSqlResult::at () const\fC [protected]\fR" Returns the current (zero-based) position of the result. .SH "TQVariant TQSqlResult::data ( int i )\fC [pure virtual protected]\fR" Returns the data for field \fIi\fR (zero-based) as a TQVariant. This function is only called if the result is in an active state and is positioned on a valid record and \fIi\fR is non-negative. Derived classes must reimplement this function and return the value of field \fIi\fR, or TQVariant() if it cannot be determined. .SH "const TQSqlDriver * TQSqlResult::driver () const\fC [protected]\fR" Returns the driver associated with the result. .SH "bool TQSqlResult::fetch ( int i )\fC [pure virtual protected]\fR" Positions the result to an arbitrary (zero-based) index \fIi\fR. 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 index \fIi\fR, and call setAt() with an appropriate value. Return TRUE to indicate success, or FALSE to signify failure. .SH "bool TQSqlResult::fetchFirst ()\fC [pure virtual protected]\fR" Positions the result to the first record 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. .SH "bool TQSqlResult::fetchLast ()\fC [pure virtual protected]\fR" Positions the result to the last record 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. .SH "bool TQSqlResult::fetchNext ()\fC [virtual protected]\fR" Positions the result to the next available record 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. .SH "bool TQSqlResult::fetchPrev ()\fC [virtual protected]\fR" Positions the result to the previous available record 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. .SH "bool TQSqlResult::isActive () const\fC [protected]\fR" Returns TRUE if the result has records to be retrieved; otherwise returns FALSE. .SH "bool TQSqlResult::isForwardOnly () const\fC [protected]\fR" Returns TRUE if you can only scroll forward through a result set; otherwise returns FALSE. .SH "bool TQSqlResult::isNull ( int i )\fC [pure virtual protected]\fR" Returns TRUE if the field at position \fIi\fR is NULL; otherwise returns FALSE. .SH "bool TQSqlResult::isSelect () const\fC [protected]\fR" Returns TRUE if the current result is from a SELECT statement; otherwise returns FALSE. .SH "bool TQSqlResult::isValid () const\fC [protected]\fR" 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. .SH "TQSqlError TQSqlResult::lastError () const\fC [protected]\fR" Returns the last error associated with the result. .SH "TQString TQSqlResult::lastQuery () const\fC [protected]\fR" Returns the current SQL query text, or TQString::null if there is none. .SH "int TQSqlResult::numRowsAffected ()\fC [pure virtual protected]\fR" Returns the number of rows affected by the last query executed. .SH "bool TQSqlResult::reset ( const TQString & query )\fC [pure virtual protected]\fR" Sets the result to use the SQL statement \fIquery\fR for subsequent data retrieval. Derived classes must reimplement this function and apply the \fIquery\fR to the database. This function is called only 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. .SH "void TQSqlResult::setActive ( bool a )\fC [virtual protected]\fR" Protected function provided for derived classes to set the internal active state to the value of \fIa\fR. .PP See also isActive(). .SH "void TQSqlResult::setAt ( int at )\fC [virtual protected]\fR" Protected function provided for derived classes to set the internal (zero-based) result index to \fIat\fR. .PP See also at(). .SH "void TQSqlResult::setForwardOnly ( bool forward )\fC [virtual protected]\fR" Sets forward only mode to \fIforward\fR. If forward is TRUE only fetchNext() is allowed for navigating the results. Forward only mode needs far less memory since results do not have to be cached. forward only mode is off by default. .PP See also fetchNext(). .SH "void TQSqlResult::setLastError ( const TQSqlError & e )\fC [virtual protected]\fR" Protected function provided for derived classes to set the last error to the value of \fIe\fR. .PP See also lastError(). .SH "void TQSqlResult::setQuery ( const TQString & query )\fC [virtual protected]\fR" Sets the current query for the result to \fIquery\fR. The result must be reset() in order to execute the query on the database. .SH "void TQSqlResult::setSelect ( bool s )\fC [virtual protected]\fR" Protected function provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement. The \fIs\fR parameter should be TRUE if the statement is a SELECT statement, or FALSE otherwise. .SH "int TQSqlResult::size ()\fC [pure virtual protected]\fR" Returns the size of the result or -1 if it cannot be determined. .SH "SEE ALSO" .BR http://doc.trolltech.com/tqsqlresult.html .BR http://www.trolltech.com/faq/tech.html .SH COPYRIGHT Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. .SH AUTHOR Generated automatically from the source code. .SH BUGS If you find a bug in Qt, please report it as described in .BR http://doc.trolltech.com/bughowto.html . Good bug reports help us to help you. Thank you. .P The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. .P If you find errors in this manual page, please report them to .BR qt-bugs@trolltech.com . Please include the name of the manual page (tqsqlresult.3qt) and the Qt version (3.3.8).