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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSqlResult Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSqlResult Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1><p>The QSqlResult class provides an abstract interface for
accessing data from specific SQL databases. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsqlresult.html#BindingSyntax-enum">BindingSyntax</a></b> { PositionalBinding, NamedBinding }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsqlresult.html#QSqlResult">__init__</a></b> (<i>self</i>, QSqlDriver <i>db</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#addBindValue">addBindValue</a></b> (<i>self</i>, QVariant <i>val</i>, QSql.ParamType <i>type</i>)</li><li><div class="fn" />int <b><a href="qsqlresult.html#at">at</a></b> (<i>self</i>)</li><li><div class="fn" />BindingSyntax <b><a href="qsqlresult.html#bindingSyntax">bindingSyntax</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#bindValue">bindValue</a></b> (<i>self</i>, int <i>pos</i>, QVariant <i>val</i>, QSql.ParamType <i>type</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#bindValue-2">bindValue</a></b> (<i>self</i>, QString <i>placeholder</i>, QVariant <i>val</i>, QSql.ParamType <i>type</i>)</li><li><div class="fn" />QSql.ParamType <b><a href="qsqlresult.html#bindValueType">bindValueType</a></b> (<i>self</i>, QString <i>placeholder</i>)</li><li><div class="fn" />QSql.ParamType <b><a href="qsqlresult.html#bindValueType-2">bindValueType</a></b> (<i>self</i>, int <i>pos</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlresult.html#boundValue">boundValue</a></b> (<i>self</i>, QString <i>placeholder</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlresult.html#boundValue-2">boundValue</a></b> (<i>self</i>, int <i>pos</i>)</li><li><div class="fn" />int <b><a href="qsqlresult.html#boundValueCount">boundValueCount</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsqlresult.html#boundValueName">boundValueName</a></b> (<i>self</i>, int <i>pos</i>)</li><li><div class="fn" />list-of-QVariant <b><a href="qsqlresult.html#boundValues">boundValues</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlresult.html#data">data</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QSqlDriver <b><a href="qsqlresult.html#driver">driver</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#exec">exec_</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsqlresult.html#executedQuery">executedQuery</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#fetch">fetch</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#fetchFirst">fetchFirst</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#fetchLast">fetchLast</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#fetchNext">fetchNext</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#fetchPrevious">fetchPrevious</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlresult.html#handle">handle</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#hasOutValues">hasOutValues</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#isActive">isActive</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#isForwardOnly">isForwardOnly</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#isNull">isNull</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#isSelect">isSelect</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QSqlError <b><a href="qsqlresult.html#lastError">lastError</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlresult.html#lastInsertId">lastInsertId</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsqlresult.html#lastQuery">lastQuery</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlresult.html#numRowsAffected">numRowsAffected</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#prepare">prepare</a></b> (<i>self</i>, QString <i>query</i>)</li><li><div class="fn" />QSqlRecord <b><a href="qsqlresult.html#record">record</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#reset">reset</a></b> (<i>self</i>, QString <i>sqlquery</i>)</li><li><div class="fn" />bool <b><a href="qsqlresult.html#savePrepare">savePrepare</a></b> (<i>self</i>, QString <i>sqlquery</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setActive">setActive</a></b> (<i>self</i>, bool <i>a</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setAt">setAt</a></b> (<i>self</i>, int <i>at</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setForwardOnly">setForwardOnly</a></b> (<i>self</i>, bool <i>forward</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setLastError">setLastError</a></b> (<i>self</i>, QSqlError <i>e</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setQuery">setQuery</a></b> (<i>self</i>, QString <i>query</i>)</li><li><div class="fn" /><b><a href="qsqlresult.html#setSelect">setSelect</a></b> (<i>self</i>, bool <i>s</i>)</li><li><div class="fn" />int <b><a href="qsqlresult.html#size">size</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSqlResult class provides an abstract interface for
accessing data from specific SQL databases.</p>
<p>Normally, you would use <a href="qsqlquery.html">QSqlQuery</a>
instead of QSqlResult, since <a href="qsqlquery.html">QSqlQuery</a>
provides a generic wrapper for database-specific implementations of
QSqlResult.</p>
<p>If you are implementing your own SQL driver (by subclassing
<a href="qsqldriver.html">QSqlDriver</a>), you will need to provide
your own QSqlResult subclass that implements all the pure virtual
functions and other virtual functions that you need.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="BindingSyntax-enum" />QSqlResult.BindingSyntax</h3><p>This enum type specifies the different syntaxes for specifying
placeholders in prepared queries.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QSqlResult.PositionalBinding</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Use the ODBC-style positional syntax, with "?"
as placeholders.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSqlResult.NamedBinding</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Use the Oracle-style syntax with named
placeholders (e.g., ":id")</td>
</tr>
</table>
<p><b>See also</b> <a href="qsqlresult.html#bindingSyntax">bindingSyntax</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSqlResult" />QSqlResult.__init__ (<i>self</i>, <a href="qsqldriver.html">QSqlDriver</a> <i>db</i>)</h3><p>Creates a <a href="qsqlresult.html">QSqlResult</a> using
database driver <i>db</i>. The object is initialized to an inactive
state.</p>
<p><b>See also</b> <a href="qsqlresult.html#isActive">isActive</a>() and <a href="qsqlresult.html#driver">driver</a>().</p>
<h3 class="fn"><a name="addBindValue" />QSqlResult.addBindValue (<i>self</i>, QVariant <i>val</i>, <a href="qsql-paramtype.html">QSql.ParamType</a> <i>type</i>)</h3><p>Binds the value <i>val</i> of parameter type <i>paramType</i> to
the next available position in the current record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#bindValue">bindValue</a>().</p>
<h3 class="fn"><a name="at" />int QSqlResult.at (<i>self</i>)</h3><p>Returns the current (zero-based) row position of the result. May
return the special values <a href="qsql.html#Location-enum">QSql.BeforeFirstRow</a> or <a href="qsql.html#Location-enum">QSql.AfterLastRow</a>.</p>
<p><b>See also</b> <a href="qsqlresult.html#setAt">setAt</a>() and
<a href="qsqlresult.html#isValid">isValid</a>().</p>
<h3 class="fn"><a name="bindingSyntax" /><a href="qsqlresult.html#BindingSyntax-enum">BindingSyntax</a> QSqlResult.bindingSyntax (<i>self</i>)</h3><p>Returns the binding syntax used by prepared queries.</p>
<h3 class="fn"><a name="bindValue" />QSqlResult.bindValue (<i>self</i>, int <i>pos</i>, QVariant <i>val</i>, <a href="qsql-paramtype.html">QSql.ParamType</a> <i>type</i>)</h3><p>Binds the value <i>val</i> of parameter type <i>paramType</i> to
position <i>index</i> in the current record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#addBindValue">addBindValue</a>().</p>
<h3 class="fn"><a name="bindValue-2" />QSqlResult.bindValue (<i>self</i>, QString <i>placeholder</i>, QVariant <i>val</i>, <a href="qsql-paramtype.html">QSql.ParamType</a> <i>type</i>)</h3><p>This is an overloaded function.</p>
<p>Binds the value <i>val</i> of parameter type <i>paramType</i> to
the <i>placeholder</i> name in the current record (row).</p>
<p>Values cannot be bound to multiple locations in the query,
eg:</p>
<pre class="cpp">
INSERT INTO testtable (id<span class="operator">,</span> name<span class="operator">,</span> samename) VALUES (:id<span class="operator">,</span> :name<span class="operator">,</span> :name)
</pre>
<p>Binding to name will bind to the first :name, but not the
second.</p>
<p><b>Note:</b> Binding an undefined placeholder will result in
undefined behavior.</p>
<p><b>See also</b> <a href="qsqlquery.html#bindValue">QSqlQuery.bindValue</a>().</p>
<h3 class="fn"><a name="bindValueType" /><a href="qsql-paramtype.html">QSql.ParamType</a> QSqlResult.bindValueType (<i>self</i>, QString <i>placeholder</i>)</h3><p>Returns the parameter type for the value bound at position
<i>index</i>.</p>
<p><b>See also</b> <a href="qsqlresult.html#boundValue">boundValue</a>().</p>
<h3 class="fn"><a name="bindValueType-2" /><a href="qsql-paramtype.html">QSql.ParamType</a> QSqlResult.bindValueType (<i>self</i>, int <i>pos</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the parameter type for the value bound with the given
<i>placeholder</i> name.</p>
<h3 class="fn"><a name="boundValue" />QVariant QSqlResult.boundValue (<i>self</i>, QString <i>placeholder</i>)</h3><p>Returns the value bound at position <i>index</i> in the current
record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#bindValue">bindValue</a>() and <a href="qsqlresult.html#boundValues">boundValues</a>().</p>
<h3 class="fn"><a name="boundValue-2" />QVariant QSqlResult.boundValue (<i>self</i>, int <i>pos</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the value bound by the given <i>placeholder</i> name in
the current record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#bindValueType">bindValueType</a>().</p>
<h3 class="fn"><a name="boundValueCount" />int QSqlResult.boundValueCount (<i>self</i>)</h3><p>Returns the number of bound values in the result.</p>
<p><b>See also</b> <a href="qsqlresult.html#boundValues">boundValues</a>().</p>
<h3 class="fn"><a name="boundValueName" />QString QSqlResult.boundValueName (<i>self</i>, int <i>pos</i>)</h3><p>Returns the name of the bound value at position <i>index</i> in
the current record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#boundValue">boundValue</a>().</p>
<h3 class="fn"><a name="boundValues" />list-of-QVariant QSqlResult.boundValues (<i>self</i>)</h3><p>Returns a vector of the result's bound values for the current
record (row).</p>
<p><b>See also</b> <a href="qsqlresult.html#boundValueCount">boundValueCount</a>().</p>
<h3 class="fn"><a name="clear" />QSqlResult.clear (<i>self</i>)</h3><p>Clears the entire result set and releases any associated
resources.</p>
<h3 class="fn"><a name="data" />QVariant QSqlResult.data (<i>self</i>, int <i>i</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the data for field <i>index</i> in the current row as a
<a href="qvariant.html">QVariant</a>. This function is only called
if the result is in an active state and is positioned on a valid
record and <i>index</i> is non-negative. Derived classes must
reimplement this function and return the value of field
<i>index</i>, or QVariant() if it cannot be determined.</p>
<h3 class="fn"><a name="driver" /><a href="qsqldriver.html">QSqlDriver</a> QSqlResult.driver (<i>self</i>)</h3><p>Returns the driver associated with the result. This is the
object that was passed to the constructor.</p>
<h3 class="fn"><a name="exec" />bool QSqlResult.exec_ (<i>self</i>)</h3><p>Executes the query, returning true if successful; otherwise
returns false.</p>
<p><b>See also</b> <a href="qsqlresult.html#prepare">prepare</a>().</p>
<h3 class="fn"><a name="executedQuery" />QString QSqlResult.executedQuery (<i>self</i>)</h3><p>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.</p>
<p><b>See also</b> <a href="qsqlresult.html#exec">exec_</a>() and
<a href="qsqlresult.html#setQuery">setQuery</a>().</p>
<h3 class="fn"><a name="fetch" />bool QSqlResult.fetch (<i>self</i>, int <i>i</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Positions the result to an arbitrary (zero-based) row
<i>index</i>.</p>
<p>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 <i>index</i>, and call <a href="qsqlresult.html#setAt">setAt</a>() with an appropriate value.
Return true to indicate success, or false to signify failure.</p>
<p><b>See also</b> <a href="qsqlresult.html#isActive">isActive</a>(), <a href="qsqlresult.html#fetchFirst">fetchFirst</a>(), <a href="qsqlresult.html#fetchLast">fetchLast</a>(), <a href="qsqlresult.html#fetchNext">fetchNext</a>(), and <a href="qsqlresult.html#fetchPrevious">fetchPrevious</a>().</p>
<h3 class="fn"><a name="fetchFirst" />bool QSqlResult.fetchFirst (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Positions the result to the first record (row 0) in the
result.</p>
<p>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 <a href="qsqlresult.html#setAt">setAt</a>() with an appropriate value.
Return true to indicate success, or false to signify failure.</p>
<p><b>See also</b> <a href="qsqlresult.html#fetch">fetch</a>() and
<a href="qsqlresult.html#fetchLast">fetchLast</a>().</p>
<h3 class="fn"><a name="fetchLast" />bool QSqlResult.fetchLast (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Positions the result to the last record (last row) in the
result.</p>
<p>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 <a href="qsqlresult.html#setAt">setAt</a>() with an appropriate value.
Return true to indicate success, or false to signify failure.</p>
<p><b>See also</b> <a href="qsqlresult.html#fetch">fetch</a>() and
<a href="qsqlresult.html#fetchFirst">fetchFirst</a>().</p>
<h3 class="fn"><a name="fetchNext" />bool QSqlResult.fetchNext (<i>self</i>)</h3><p>Positions the result to the next available record (row) in the
result.</p>
<p>This function is only called if the result is in an active
state. The default implementation calls <a href="qsqlresult.html#fetch">fetch</a>() with the next index. Derived
classes can reimplement this function and position the result to
the next record in some other way, and call <a href="qsqlresult.html#setAt">setAt</a>() with an appropriate value.
Return true to indicate success, or false to signify failure.</p>
<p><b>See also</b> <a href="qsqlresult.html#fetch">fetch</a>() and
<a href="qsqlresult.html#fetchPrevious">fetchPrevious</a>().</p>
<h3 class="fn"><a name="fetchPrevious" />bool QSqlResult.fetchPrevious (<i>self</i>)</h3><p>Positions the result to the previous record (row) in the
result.</p>
<p>This function is only called if the result is in an active
state. The default implementation calls <a href="qsqlresult.html#fetch">fetch</a>() with the previous index.
Derived classes can reimplement this function and position the
result to the next record in some other way, and call <a href="qsqlresult.html#setAt">setAt</a>() with an appropriate value.
Return true to indicate success, or false to signify failure.</p>
<h3 class="fn"><a name="handle" />QVariant QSqlResult.handle (<i>self</i>)</h3><p>Returns the low-level database handle for this result set
wrapped in a <a href="qvariant.html">QVariant</a> or an invalid
<a href="qvariant.html">QVariant</a> if there is no handle.</p>
<p><b>Warning:</b> Use this with uttermost care and only if you
know what you're doing.</p>
<p><b>Warning:</b> The handle returned here can become a stale
pointer if the result is modified (for example, if you clear
it).</p>
<p><b>Warning:</b> The handle can be NULL if the result was not
executed yet.</p>
<p>The handle returned here is database-dependent, you should query
the type name of the variant before accessing it.</p>
<p>This example retrieves the handle for a sqlite result:</p>
<pre class="cpp">
<span class="type"><a href="qsqlquery.html">QSqlQuery</a></span> query <span class="operator">=</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
<span class="type"><a href="qvariant.html">QVariant</a></span> v <span class="operator">=</span> query<span class="operator">.</span>result()<span class="operator">-</span><span class="operator">></span>handle();
<span class="keyword">if</span> (v<span class="operator">.</span>isValid() <span class="operator">&</span><span class="operator">&</span> qstrcmp(v<span class="operator">.</span>typeName()<span class="operator">,</span> <span class="string">"sqlite3_stmt*"</span>)) {
<span class="comment">// v.data() returns a pointer to the handle</span>
sqlite3_stmt <span class="operator">*</span>handle <span class="operator">=</span> <span class="operator">*</span><span class="keyword">static_cast</span><span class="operator"><</span>sqlite3_stmt <span class="operator">*</span><span class="operator">*</span><span class="operator">></span>(v<span class="operator">.</span>data());
<span class="keyword">if</span> (handle <span class="operator">!</span><span class="operator">=</span> <span class="number">0</span>) { <span class="comment">// check that it is not NULL</span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
}
</pre>
<p>This snippet returns the handle for PostgreSQL or MySQL:</p>
<pre class="cpp">
<span class="keyword">if</span> (v<span class="operator">.</span>typeName() <span class="operator">=</span><span class="operator">=</span> <span class="string">"PGresult*"</span>) {
PGresult <span class="operator">*</span>handle <span class="operator">=</span> <span class="operator">*</span><span class="keyword">static_cast</span><span class="operator"><</span>PGresult <span class="operator">*</span><span class="operator">*</span><span class="operator">></span>(v<span class="operator">.</span>data());
<span class="keyword">if</span> (handle <span class="operator">!</span><span class="operator">=</span> <span class="number">0</span>) <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
<span class="keyword">if</span> (v<span class="operator">.</span>typeName() <span class="operator">=</span><span class="operator">=</span> <span class="string">"MYSQL_STMT*"</span>) {
MYSQL_STMT <span class="operator">*</span>handle <span class="operator">=</span> <span class="operator">*</span><span class="keyword">static_cast</span><span class="operator"><</span>MYSQL_STMT <span class="operator">*</span><span class="operator">*</span><span class="operator">></span>(v<span class="operator">.</span>data());
<span class="keyword">if</span> (handle <span class="operator">!</span><span class="operator">=</span> <span class="number">0</span>) <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
</pre>
<p><b>See also</b> <a href="qsqldriver.html#handle">QSqlDriver.handle</a>().</p>
<h3 class="fn"><a name="hasOutValues" />bool QSqlResult.hasOutValues (<i>self</i>)</h3><p>Returns true if at least one of the query's bound values is a
<tt>QSql.Out</tt> or a <a href="qsql.html#ParamTypeFlag-enum">QSql.InOut</a>; otherwise returns
false.</p>
<p><b>See also</b> <a href="qsqlresult.html#bindValueType">bindValueType</a>().</p>
<h3 class="fn"><a name="isActive" />bool QSqlResult.isActive (<i>self</i>)</h3><p>Returns true if the result has records to be retrieved;
otherwise returns false.</p>
<h3 class="fn"><a name="isForwardOnly" />bool QSqlResult.isForwardOnly (<i>self</i>)</h3><p>Returns true if you can only scroll forward through the result
set; otherwise returns false.</p>
<p><b>See also</b> <a href="qsqlresult.html#setForwardOnly">setForwardOnly</a>().</p>
<h3 class="fn"><a name="isNull" />bool QSqlResult.isNull (<i>self</i>, int <i>i</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the field at position <i>index</i> in the
current row is null; otherwise returns false.</p>
<h3 class="fn"><a name="isSelect" />bool QSqlResult.isSelect (<i>self</i>)</h3><p>Returns true if the current result is from a <tt>SELECT</tt>
statement; otherwise returns false.</p>
<p><b>See also</b> <a href="qsqlresult.html#setSelect">setSelect</a>().</p>
<h3 class="fn"><a name="isValid" />bool QSqlResult.isValid (<i>self</i>)</h3><p>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.</p>
<p><b>See also</b> <a href="qsqlresult.html#at">at</a>().</p>
<h3 class="fn"><a name="lastError" /><a href="qsqlerror.html">QSqlError</a> QSqlResult.lastError (<i>self</i>)</h3><p>Returns the last error associated with the result.</p>
<p><b>See also</b> <a href="qsqlresult.html#setLastError">setLastError</a>().</p>
<h3 class="fn"><a name="lastInsertId" />QVariant QSqlResult.lastInsertId (<i>self</i>)</h3><p>Returns the object ID of the most recent inserted row if the
database supports it. An invalid <a href="qvariant.html">QVariant</a> 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.</p>
<p>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.</p>
<p><b>See also</b> <a href="qsqldriver.html#hasFeature">QSqlDriver.hasFeature</a>().</p>
<h3 class="fn"><a name="lastQuery" />QString QSqlResult.lastQuery (<i>self</i>)</h3><p>Returns the current SQL query text, or an empty string if there
isn't one.</p>
<p><b>See also</b> <a href="qsqlresult.html#setQuery">setQuery</a>().</p>
<h3 class="fn"><a name="numRowsAffected" />int QSqlResult.numRowsAffected (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the number of rows affected by the last query executed,
or -1 if it cannot be determined or if the query is a
<tt>SELECT</tt> statement.</p>
<p><b>See also</b> <a href="qsqlresult.html#size">size</a>().</p>
<h3 class="fn"><a name="prepare" />bool QSqlResult.prepare (<i>self</i>, QString <i>query</i>)</h3><p>Prepares the given <i>query</i> 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.</p>
<p><b>See also</b> <a href="qsqlresult.html#exec">exec_</a>().</p>
<h3 class="fn"><a name="record" /><a href="qsqlrecord.html">QSqlRecord</a> QSqlResult.record (<i>self</i>)</h3><p>Returns the current record if the query is active; otherwise
returns an empty <a href="qsqlrecord.html">QSqlRecord</a>.</p>
<p>The default implementation always returns an empty <a href="qsqlrecord.html">QSqlRecord</a>.</p>
<p><b>See also</b> <a href="qsqlresult.html#isActive">isActive</a>().</p>
<h3 class="fn"><a name="reset" />bool QSqlResult.reset (<i>self</i>, QString <i>sqlquery</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Sets the result to use the SQL statement <i>query</i> for
subsequent data retrieval.</p>
<p>Derived classes must reimplement this function and apply the
<i>query</i> 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.</p>
<p><b>See also</b> <a href="qsqlresult.html#setQuery">setQuery</a>().</p>
<h3 class="fn"><a name="savePrepare" />bool QSqlResult.savePrepare (<i>self</i>, QString <i>sqlquery</i>)</h3><p>Prepares the given <i>query</i>, using the underlying database
functionality where possible. Returns true if the query is prepared
successfully; otherwise returns false.</p>
<p><b>See also</b> <a href="qsqlresult.html#prepare">prepare</a>().</p>
<h3 class="fn"><a name="setActive" />QSqlResult.setActive (<i>self</i>, bool <i>a</i>)</h3><p>This function is provided for derived classes to set the
internal active state to <i>active</i>.</p>
<p><b>See also</b> <a href="qsqlresult.html#isActive">isActive</a>().</p>
<h3 class="fn"><a name="setAt" />QSqlResult.setAt (<i>self</i>, int <i>at</i>)</h3><p>This function is provided for derived classes to set the
internal (zero-based) row position to <i>index</i>.</p>
<p><b>See also</b> <a href="qsqlresult.html#at">at</a>().</p>
<h3 class="fn"><a name="setForwardOnly" />QSqlResult.setForwardOnly (<i>self</i>, bool <i>forward</i>)</h3><p>Sets forward only mode to <i>forward</i>. If <i>forward</i> is
true, only <a href="qsqlresult.html#fetchNext">fetchNext</a>() 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.</p>
<p>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. <a href="qsqlresult.html#isForwardOnly">isForwardOnly</a>() will always
return the correct status of the result set.</p>
<p><b>Note:</b> Calling setForwardOnly after execution of the query
will result in unexpected results at best, and crashes at
worst.</p>
<p><b>See also</b> <a href="qsqlresult.html#isForwardOnly">isForwardOnly</a>(), <a href="qsqlresult.html#fetchNext">fetchNext</a>(), and <a href="qsqlquery.html#setForwardOnly">QSqlQuery.setForwardOnly</a>().</p>
<h3 class="fn"><a name="setLastError" />QSqlResult.setLastError (<i>self</i>, <a href="qsqlerror.html">QSqlError</a> <i>e</i>)</h3><p>This function is provided for derived classes to set the last
error to <i>error</i>.</p>
<p><b>See also</b> <a href="qsqlresult.html#lastError">lastError</a>().</p>
<h3 class="fn"><a name="setQuery" />QSqlResult.setQuery (<i>self</i>, QString <i>query</i>)</h3><p>Sets the current query for the result to <i>query</i>. You must
call <a href="qsqlresult.html#reset">reset</a>() to execute the
query on the database.</p>
<p><b>See also</b> <a href="qsqlresult.html#reset">reset</a>() and
<a href="qsqlresult.html#lastQuery">lastQuery</a>().</p>
<h3 class="fn"><a name="setSelect" />QSqlResult.setSelect (<i>self</i>, bool <i>s</i>)</h3><p>This function is provided for derived classes to indicate
whether or not the current statement is a SQL <tt>SELECT</tt>
statement. The <i>select</i> parameter should be true if the
statement is a <tt>SELECT</tt> statement; otherwise it should be
false.</p>
<p><b>See also</b> <a href="qsqlresult.html#isSelect">isSelect</a>().</p>
<h3 class="fn"><a name="size" />int QSqlResult.size (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the size of the <tt>SELECT</tt> result, or -1 if it
cannot be determined or if the query is not a <tt>SELECT</tt>
statement.</p>
<p><b>See also</b> <a href="qsqlresult.html#numRowsAffected">numRowsAffected</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|