1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
'\" t
.TH QSqlResult 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
QSqlResult \- Abstract interface for accessing data from SQL databases
.SH SYNOPSIS
\fC#include <qsqlresult.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "virtual \fB~QSqlResult\fR ()"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "\fBQSqlResult\fR ( const QSqlDriver * db )"
.br
.ti -1c
.BI "int \fBat\fR () const"
.br
.ti -1c
.BI "QString \fBlastQuery\fR () const"
.br
.ti -1c
.BI "QSqlError \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 QSqlDriver * \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 QSqlError & e )"
.br
.ti -1c
.BI "virtual void \fBsetQuery\fR ( const QString & 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 QVariant \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 QString & 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 QSqlResult class provides an abstract interface for accessing data from SQL databases.
.PP
Normally you would use QSqlQuery instead of QSqlResult since QSqlQuery provides a generic wrapper for database-specific implementations of QSqlResult.
.PP
See also QSql and Database Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QSqlResult::QSqlResult ( const QSqlDriver * db )\fC [protected]\fR"
Protected constructor which creates a QSqlResult using database \fIdb\fR. The object is initialized to an inactive state.
.SH "QSqlResult::~QSqlResult ()\fC [virtual]\fR"
Destroys the object and frees any allocated resources.
.SH "int QSqlResult::at () const\fC [protected]\fR"
Returns the current (zero-based) position of the result.
.SH "QVariant QSqlResult::data ( int i )\fC [pure virtual protected]\fR"
Returns the data for field \fIi\fR (zero-based) as a QVariant. 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 QVariant() if it cannot be determined.
.SH "const QSqlDriver * QSqlResult::driver () const\fC [protected]\fR"
Returns the driver associated with the result.
.SH "bool QSqlResult::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 QSqlResult::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 QSqlResult::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 QSqlResult::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 QSqlResult::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 QSqlResult::isActive () const\fC [protected]\fR"
Returns TRUE if the result has records to be retrieved; otherwise returns FALSE.
.SH "bool QSqlResult::isForwardOnly () const\fC [protected]\fR"
Returns TRUE if you can only scroll forward through a result set; otherwise returns FALSE.
.SH "bool QSqlResult::isNull ( int i )\fC [pure virtual protected]\fR"
Returns TRUE if the field at position \fIi\fR is NULL; otherwise returns FALSE.
.SH "bool QSqlResult::isSelect () const\fC [protected]\fR"
Returns TRUE if the current result is from a SELECT statement; otherwise returns FALSE.
.SH "bool QSqlResult::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 "QSqlError QSqlResult::lastError () const\fC [protected]\fR"
Returns the last error associated with the result.
.SH "QString QSqlResult::lastQuery () const\fC [protected]\fR"
Returns the current SQL query text, or QString::null if there is none.
.SH "int QSqlResult::numRowsAffected ()\fC [pure virtual protected]\fR"
Returns the number of rows affected by the last query executed.
.SH "bool QSqlResult::reset ( const QString & 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 QSqlResult::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 QSqlResult::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 QSqlResult::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 QSqlResult::setLastError ( const QSqlError & 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 QSqlResult::setQuery ( const QString & 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 QSqlResult::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 QSqlResult::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/qsqlresult.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 Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt 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 (qsqlresult.3qt) and the Qt
version (3.3.8).
|