<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>TQSqlQuery Class Reference<br><small>[<ahref="sql.html">sql module</a>]</small></h1>
<p>The TQSqlQuery class provides a means of executing and
int i = query.<ahref="#boundValue">boundValue</a>( 1 ).toInt(); // i is 65.
</pre>
<p><p>See also <ahref="qsqldatabase.html">TQSqlDatabase</a>, <ahref="qsqlcursor.html">TQSqlCursor</a>, <ahref="qvariant.html">TQVariant</a>, and <ahref="database.html">Database Classes</a>.
Adds the value <em>val</em> to the list of values when using positional
value binding. The order of the <ahref="#addBindValue">addBindValue</a>() calls determines
which placeholder a value will be bound to in the prepared query.
If <em>type</em> is <ahref="qsql.html#ParameterType-enum">TQSql::Out</a> or <ahref="qsql.html#ParameterType-enum">TQSql::InOut</a>, the placeholder will
be overwritten with data from the database after the <ahref="#exec">exec</a>() call.
<p><p>See also <ahref="#bindValue">bindValue</a>(), <ahref="#prepare">prepare</a>(), and <ahref="#exec">exec</a>().
Returns the current internal position of the query. The first
record is at position zero. If the position is invalid, a
TQSql::Location will be returned indicating the invalid position.
<p><p>See also <ahref="#prev">prev</a>(), <ahref="#next">next</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), <ahref="#seek">seek</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
Executes the SQL in <em>query</em>. Returns TRUE and sets the query
state to active if the query was successful; otherwise returns
FALSE and sets the query state to inactive. The <em>query</em> string
must use syntax appropriate for the SQL database being queried,
for example, standard SQL.
<p> After the query is executed, the query is positioned on an <em>invalid</em> record, and must be navigated to a valid record before
data values can be retrieved, e.g. using <ahref="#next">next</a>().
<p> Note that the last error for this query is reset when <ahref="#exec">exec</a>() is
called.
<p><p>See also <ahref="#isActive">isActive</a>(), <ahref="#isValid">isValid</a>(), <ahref="#next">next</a>(), <ahref="#prev">prev</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), and <ahref="#seek">seek</a>().
<p>Examples: <ahref="sql.html#x2157">sql/overview/basicbrowsing/main.cpp</a>, <ahref="sql.html#x2161">sql/overview/basicbrowsing2/main.cpp</a>, <ahref="sql.html#x2166">sql/overview/basicdatamanip/main.cpp</a>, and <ahref="sql.html#x2154">sql/overview/connection.cpp</a>.
Retrieves the first record in the result, if available, and
positions the query on the retrieved record. Note that the result
must be in an active state and <ahref="#isSelect">isSelect</a>() must return TRUE before
calling this function or it will do nothing and return FALSE.
Returns TRUE if successful. If unsuccessful the query position is
set to an invalid position and FALSE is returned.
<p><p>See also <ahref="#next">next</a>(), <ahref="#prev">prev</a>(), <ahref="#last">last</a>(), <ahref="#seek">seek</a>(), <ahref="#at">at</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
Retrieves the last record in the result, if available, and
positions the query on the retrieved record. Note that the result
must be in an active state and <ahref="#isSelect">isSelect</a>() must return TRUE before
calling this function or it will do nothing and return FALSE.
Returns TRUE if successful. If unsuccessful the query position is
set to an invalid position and FALSE is returned.
<p><p>See also <ahref="#next">next</a>(), <ahref="#prev">prev</a>(), <ahref="#first">first</a>(), <ahref="#seek">seek</a>(), <ahref="#at">at</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
Retrieves the next record in the result, if available, and
positions the query on the retrieved record. Note that the result
must be in an active state and <ahref="#isSelect">isSelect</a>() must return TRUE before
calling this function or it will do nothing and return FALSE.
<p> The following rules apply:
<p><ul>
<li> If the result is currently located before the first
record, e.g. immediately after a query is executed, an attempt is
made to retrieve the first record.
<p><li> If the result is currently located after the last record,
there is no change and FALSE is returned.
<p><li> If the result is located somewhere in the middle, an attempt
is made to retrieve the next record.
</ul>
<p> If the record could not be retrieved, the result is positioned after
the last record and FALSE is returned. If the record is successfully
retrieved, TRUE is returned.
<p><p>See also <ahref="#prev">prev</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), <ahref="#seek">seek</a>(), <ahref="#at">at</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
<p>Examples: <ahref="sql.html#x2159">sql/overview/basicbrowsing/main.cpp</a>, <ahref="sql.html#x2163">sql/overview/basicbrowsing2/main.cpp</a>, <ahref="sql.html#x2208">sql/overview/delete/main.cpp</a>, <ahref="sql.html#x2183">sql/overview/order1/main.cpp</a>, <ahref="sql.html#x2176">sql/overview/retrieve1/main.cpp</a>, <ahref="sql.html#x2265">sql/overview/subclass4/main.cpp</a>, and <ahref="sql.html#x2268">sql/overview/subclass5/main.cpp</a>.
Retrieves the previous record in the result, if available, and
positions the query on the retrieved record. Note that the result
must be in an active state and <ahref="#isSelect">isSelect</a>() must return TRUE before
calling this function or it will do nothing and return FALSE.
<p> The following rules apply:
<p><ul>
<li> If the result is currently located before the first record,
there is no change and FALSE is returned.
<p><li> If the result is currently located after the last record, an
attempt is made to retrieve the last record.
<p><li> If the result is somewhere in the middle, an attempt is made
to retrieve the previous record.
</ul>
<p> If the record could not be retrieved, the result is positioned
before the first record and FALSE is returned. If the record is
successfully retrieved, TRUE is returned.
<p><p>See also <ahref="#next">next</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), <ahref="#seek">seek</a>(), <ahref="#at">at</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
Retrieves the record at position (offset) <em>i</em>, if available, and
positions the query on the retrieved record. The first record is
at position 0. Note that the query must be in an active state and
<ahref="#isSelect">isSelect</a>() must return TRUE before calling this function.
<p> If <em>relative</em> is FALSE (the default), the following rules apply:
<p><ul>
<li> If <em>i</em> is negative, the result is positioned before the
first record and FALSE is returned.
<li> Otherwise, an attempt is made to move to the record at position
<em>i</em>. If the record at position <em>i</em> could not be retrieved, the
result is positioned after the last record and FALSE is returned. If
the record is successfully retrieved, TRUE is returned.
</ul>
<p> If <em>relative</em> is TRUE, the following rules apply:
<p><ul>
<li> If the result is currently positioned before the first
record or on the first record, and <em>i</em> is negative, there is no
change, and FALSE is returned.
<li> If the result is currently located after the last record, and
<em>i</em> is positive, there is no change, and FALSE is returned.
<li> If the result is currently located somewhere in the middle,
and the relative offset <em>i</em> moves the result below zero, the
result is positioned before the first record and FALSE is
returned.
<li> Otherwise, an attempt is made to move to the record <em>i</em>
records ahead of the current record (or <em>i</em> records behind the
current record if <em>i</em> is negative). If the record at offset <em>i</em>
could not be retrieved, the result is positioned after the last
record if <em>i</em> >= 0, (or before the first record if <em>i</em> is
negative), and FALSE is returned. If the record is successfully
retrieved, TRUE is returned.
</ul>
<p><p>See also <ahref="#next">next</a>(), <ahref="#prev">prev</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), <ahref="#at">at</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
Returns the size of the result, (number of rows returned), or -1
if the size cannot be determined or if the database does not
support reporting information about query sizes. Note that for
non-<tt>SELECT</tt> statements (<ahref="#isSelect">isSelect</a>() returns FALSE), <ahref="#size">size</a>() will
return -1. If the query is not active (<ahref="#isActive">isActive</a>() returns FALSE),
-1 is returned.
<p> To determine the number of rows affected by a non-SELECT
statement, use <ahref="#numRowsAffected">numRowsAffected</a>().
<p><p>See also <ahref="#isActive">isActive</a>(), <ahref="#numRowsAffected">numRowsAffected</a>(), and <ahref="qsqldriver.html#hasFeature">TQSqlDriver::hasFeature</a>().
Returns the value of the <em>i</em>-th field in the query (zero based).
<p> The fields are numbered from left to right using the text of the
<tt>SELECT</tt> statement, e.g. in <tt>SELECT forename, surname FROM people</tt>,
field 0 is <tt>forename</tt> and field 1 is <tt>surname</tt>. Using <tt>SELECT *</tt>
is not recommended because the order of the fields in the query is
undefined.
<p> An invalid <ahref="qvariant.html">TQVariant</a> is returned if field <em>i</em> does not exist, if
the query is inactive, or if the query is positioned on an invalid
record.
<p><p>See also <ahref="#prev">prev</a>(), <ahref="#next">next</a>(), <ahref="#first">first</a>(), <ahref="#last">last</a>(), <ahref="#seek">seek</a>(), <ahref="#isActive">isActive</a>(), and <ahref="#isValid">isValid</a>().
<p>Examples: <ahref="sql.html#x2160">sql/overview/basicbrowsing/main.cpp</a>, <ahref="sql.html#x2165">sql/overview/basicbrowsing2/main.cpp</a>, <ahref="sql.html#x2177">sql/overview/retrieve1/main.cpp</a>, <ahref="sql.html#x2262">sql/overview/subclass3/main.cpp</a>, <ahref="sql.html#x2266">sql/overview/subclass4/main.cpp</a>, <ahref="sql.html#x2269">sql/overview/subclass5/main.cpp</a>, and <ahref="sql.html#x2252">sql/overview/table4/main.cpp</a>.
<!-- eof -->
<hr><p>
This file is part of the <ahref="index.html">TQt toolkit</a>.