📄 step.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Evaluate An SQL Statement</title><style type="text/css">body { margin: auto; font-family: "Verdana" "sans-serif"; padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline { float:right; text-align:right; font-style:italic; width:240px; margin:12px; margin-top:58px;}.toolbar { font-variant: small-caps; text-align: center; line-height: 1.6em; margin: 0; padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se { background: url(../images/se.png) 100% 100% no-repeat #80a796}.sw { background: url(../images/sw.png) 0% 100% no-repeat }.ne { background: url(../images/ne.png) 100% 0% no-repeat }.nw { background: url(../images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head><body><div><!-- container div to satisfy validator --><a href="../index.html"><img class="logo" src="../images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td> <div class="se"><div class="sw"><div class="ne"><div class="nw"> <div class="toolbar"> <a href="../about.html">About</a> <a href="../sitemap.html">Sitemap</a> <a href="../docs.html">Documentation</a> <a href="../download.html">Download</a> <a href="../copyright.html">License</a> <a href="../news.html">News</a> <a href="http://www.sqlite.org/cvstrac/index">Developers</a> <a href="../support.html">Support</a> </div></div></div></div></div></td></tr></table> <a href="intro.html"><h2>SQLite C Interface</h2></a><h2>Evaluate An SQL Statement</h2><blockquote><pre>int sqlite3_step(sqlite3_stmt*);</pre></blockquote><p>After an <a href="../c3ref/stmt.html">prepared statement</a> has been prepared with a callto either <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> or to one ofthe legacy interfaces <a href="../c3ref/prepare.html">sqlite3_prepare()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>,then this function must be called one or more times to evaluate thestatement.</p><p>The details of the behavior of this sqlite3_step() interface dependon whether the statement was prepared using the newer "v2" interface<a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> and <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> or the older legacyinterface <a href="../c3ref/prepare.html">sqlite3_prepare()</a> and <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>. The use of thenew "v2" interface is recommended for new applications but the legacyinterface will continue to be supported.</p><p>In the lagacy interface, the return value will be either <a href="../c3ref/c_abort.html">SQLITE_BUSY</a>,<a href="../c3ref/c_abort.html">SQLITE_DONE</a>, <a href="../c3ref/c_abort.html">SQLITE_ROW</a>, <a href="../c3ref/c_abort.html">SQLITE_ERROR</a>, or <a href="../c3ref/c_abort.html">SQLITE_MISUSE</a>.With the "v2" interface, any of the other <a href="../c3ref/c_abort.html">result code</a>or <a href="../c3ref/c_ioerr_blocked.html">extended result code</a> might be returned aswell.</p><p><a href="../c3ref/c_abort.html">SQLITE_BUSY</a> means that the database engine was unable to acquire thedatabase locks it needs to do its job. If the statement is a COMMITor occurs outside of an explicit transaction, then you can retry thestatement. If the statement is not a COMMIT and occurs within aexplicit transaction then you should rollback the transaction beforecontinuing.</p><p><a href="../c3ref/c_abort.html">SQLITE_DONE</a> means that the statement has finished executingsuccessfully. sqlite3_step() should not be called again on this virtualmachine without first calling <a href="../c3ref/reset.html">sqlite3_reset()</a> to reset the virtualmachine back to its initial state.</p><p>If the SQL statement being executed returns any data, then<a href="../c3ref/c_abort.html">SQLITE_ROW</a> is returned each time a new row of data is readyfor processing by the caller. The values may be accessed usingthe <a href="../c3ref/column_blob.html">column access functions</a>.sqlite3_step() is called again to retrieve the next row of data.</p><p><a href="../c3ref/c_abort.html">SQLITE_ERROR</a> means that a run-time error (such as a constraintviolation) has occurred. sqlite3_step() should not be called again onthe VM. More information may be found by calling <a href="../c3ref/errcode.html">sqlite3_errmsg()</a>.With the legacy interface, a more specific error code (example:<a href="../c3ref/c_abort.html">SQLITE_INTERRUPT</a>, <a href="../c3ref/c_abort.html">SQLITE_SCHEMA</a>, <a href="../c3ref/c_abort.html">SQLITE_CORRUPT</a>, and so forth)can be obtained by calling <a href="../c3ref/reset.html">sqlite3_reset()</a> on the<a href="../c3ref/stmt.html">prepared statement</a>. In the "v2" interface,the more specific error code is returned directly by sqlite3_step().</p><p><a href="../c3ref/c_abort.html">SQLITE_MISUSE</a> means that the this routine was called inappropriately.Perhaps it was called on a <a href="../c3ref/stmt.html">prepared statement</a> that hasalready been <a href="../c3ref/finalize.html">finalized</a> or on one that hadpreviously returned <a href="../c3ref/c_abort.html">SQLITE_ERROR</a> or <a href="../c3ref/c_abort.html">SQLITE_DONE</a>. Or it couldbe the case that the same database connection is being used by two ormore threads at the same moment in time.</p><p><b>Goofy Interface Alert:</b>In the legacy interface,the sqlite3_step() API always returns a generic error code,<a href="../c3ref/c_abort.html">SQLITE_ERROR</a>, following any error other than <a href="../c3ref/c_abort.html">SQLITE_BUSY</a>and <a href="../c3ref/c_abort.html">SQLITE_MISUSE</a>. You must call <a href="../c3ref/reset.html">sqlite3_reset()</a> or<a href="../c3ref/finalize.html">sqlite3_finalize()</a> in order to find one of the specific<a href="../c3ref/c_abort.html">error codes</a> that better describes the error.We admit that this is a goofy design. The problem has been fixedwith the "v2" interface. If you prepare all of your SQL statementsusing either <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> insteadof the legacy <a href="../c3ref/prepare.html">sqlite3_prepare()</a> and <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>, then themore specific <a href="../c3ref/c_abort.html">error codes</a> are returned directlyby sqlite3_step(). The use of the "v2" interface is recommended.</p><p><h3>Invariants:</h3><table border="0" cellpadding="5" cellspacing="0"><tr><td valign="top">F13202</td> <td valign="top">If <a href="../c3ref/stmt.html">prepared statement</a> S is ready to berun, then <a href="../c3ref/step.html">sqlite3_step(S)</a> advances that prepared statementuntil to completion or until it is ready to return anotherrow of the result set or an interrupt or run-time error occurs.</td></tr><tr><td valign="top">F15304</td> <td valign="top">When a call to <a href="../c3ref/step.html">sqlite3_step(S)</a> causes the<a href="../c3ref/stmt.html">prepared statement</a> S to run to completion,the function returns <a href="../c3ref/c_abort.html">SQLITE_DONE</a>.</td></tr><tr><td valign="top">F15306</td> <td valign="top">When a call to <a href="../c3ref/step.html">sqlite3_step(S)</a> stops because it is readyto return another row of the result set, it returns<a href="../c3ref/c_abort.html">SQLITE_ROW</a>.</td></tr><tr><td valign="top">F15308</td> <td valign="top">If a call to <a href="../c3ref/step.html">sqlite3_step(S)</a> encounters an<a href="../c3ref/interrupt.html">interrupt</a> or a run-time error,it returns an appropraite error code that is not one of<a href="../c3ref/c_abort.html">SQLITE_OK</a>, <a href="../c3ref/c_abort.html">SQLITE_ROW</a>, or <a href="../c3ref/c_abort.html">SQLITE_DONE</a>.</td></tr><tr><td valign="top">F15310</td> <td valign="top">If an <a href="../c3ref/interrupt.html">interrupt</a> or run-time erroroccurs during a call to <a href="../c3ref/step.html">sqlite3_step(S)</a>for a <a href="../c3ref/stmt.html">prepared statement</a> S created usinglegacy interfaces <a href="../c3ref/prepare.html">sqlite3_prepare()</a> or<a href="../c3ref/prepare.html">sqlite3_prepare16()</a> then the function returns either<a href="../c3ref/c_abort.html">SQLITE_ERROR</a>, <a href="../c3ref/c_abort.html">SQLITE_BUSY</a>, or <a href="../c3ref/c_abort.html">SQLITE_MISUSE</a>.</td></tr></table></p><p>See also lists of <a href="objlist.html">Objects</a>, <a href="constlist.html">Constants</a>, and <a href="funclist.html">Functions</a>.</p><hr><small<i>This page last modified 2008/01/31 20:37:13 UTC</i></small></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -