Debian Codegraph @

www/c3ref/step.html

raw
1 <!DOCTYPE html>
2 <html><head>
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <link href="../sqlite.css" rel="stylesheet">
6 <title>Evaluate An SQL Statement</title>
7 <!-- path=../ -->
8 </head>
9 <body>
10 <div class=nosearch>
11 <a href="../index.html">
12 <img class="logo" src="../images/sqlite370_banner.svg" alt="SQLite" border="0">
13 </a>
14 <div><!-- IE hack to prevent disappearing logo --></div>
15 <div class="tagline desktoponly">
16 Small. Fast. Reliable.<br>Choose any three.
17 </div>
18 <div class="menu mainmenu">
19 <ul>
20 <li><a href="../index.html">Home</a>
21 <li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
22 <li class='wideonly'><a href='../about.html'>About</a>
23 <li class='desktoponly'><a href="../docs.html">Documentation</a>
24 <li class='desktoponly'><a href="../download.html">Download</a>
25 <li class='wideonly'><a href='../copyright.html'>License</a>
26 <li class='desktoponly'><a href="../support.html">Support</a>
27 <li class='desktoponly'><a href="../prosupport.html">Purchase</a>
28 <li class='search' id='search_menubutton'>
29 <a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
30 </ul>
31 </div>
32 <div class="menu submenu" id="submenu">
33 <ul>
34 <li><a href='../about.html'>About</a>
35 <li><a href='../docs.html'>Documentation</a>
36 <li><a href='../download.html'>Download</a>
37 <li><a href='../support.html'>Support</a>
38 <li><a href='../prosupport.html'>Purchase</a>
39 </ul>
40 </div>
41 <div class="searchmenu" id="searchmenu">
42 <form method="GET" action="../search">
43 <select name="s" id="searchtype">
44 <option value="d">Search Documentation</option>
45 <option value="c">Search Changelog</option>
46 </select>
47 <input type="text" name="q" id="searchbox" value="">
48 <input type="submit" value="Go">
49 </form>
50 </div>
51 </div>
52 <script>
53 function toggle_div(nm) {
54 var w = document.getElementById(nm);
55 if( w.style.display=="block" ){
56 w.style.display = "none";
57 }else{
58 w.style.display = "block";
59 }
60 }
61 function toggle_search() {
62 var w = document.getElementById("searchmenu");
63 if( w.style.display=="block" ){
64 w.style.display = "none";
65 } else {
66 w.style.display = "block";
67 setTimeout(function(){
68 document.getElementById("searchbox").focus()
69 }, 30);
70 }
71 }
72 function div_off(nm){document.getElementById(nm).style.display="none";}
73 window.onbeforeunload = function(e){div_off("submenu");}
74 /* Disable the Search feature if we are not operating from CGI, since */
75 /* Search is accomplished using CGI and will not work without it. */
76 if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
77 document.getElementById("search_menubutton").style.display = "none";
78 }
79 /* Used by the Hide/Show button beside syntax diagrams, to toggle the */
80 function hideorshow(btn,obj){
81 var x = document.getElementById(obj);
82 var b = document.getElementById(btn);
83 if( x.style.display!='none' ){
84 x.style.display = 'none';
85 b.innerHTML='show';
86 }else{
87 x.style.display = '';
88 b.innerHTML='hide';
89 }
90 return false;
91 }
92 var antiRobot = 0;
93 function antiRobotGo(){
94 if( antiRobot!=3 ) return;
95 antiRobot = 7;
96 var j = document.getElementById("mtimelink");
97 if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
98 }
99 function antiRobotDefense(){
100 document.body.onmousedown=function(){
101 antiRobot |= 2;
102 antiRobotGo();
103 document.body.onmousedown=null;
104 }
105 document.body.onmousemove=function(){
106 antiRobot |= 2;
107 antiRobotGo();
108 document.body.onmousemove=null;
109 }
110 setTimeout(function(){
111 antiRobot |= 1;
112 antiRobotGo();
113 }, 100)
114 antiRobotGo();
115 }
116 antiRobotDefense();
117 </script>
118 <!-- keywords: sqlite3_step -->
119 <div class=nosearch>
120 <a href="../c3ref/intro.html"><h2>SQLite C Interface</h2></a>
121 <h2>Evaluate An SQL Statement</h2>
122 </div>
123 <blockquote><pre>
124 int sqlite3_step(sqlite3_stmt*);
125 </pre></blockquote>
126 <p>
127 After a <a href="../c3ref/stmt.html">prepared statement</a> has been prepared using any of
128 <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="../c3ref/prepare.html">sqlite3_prepare_v3()</a>, <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a>,
129 or <a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a> or one of the legacy
130 interfaces <a href="../c3ref/prepare.html">sqlite3_prepare()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>, this function
131 must be called one or more times to evaluate the statement.</p>
132
133 <p>The details of the behavior of the sqlite3_step() interface depend
134 on whether the statement was prepared using the newer "vX" interfaces
135 <a href="../c3ref/prepare.html">sqlite3_prepare_v3()</a>, <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a>, <a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a>,
136 <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> or the older legacy
137 interfaces <a href="../c3ref/prepare.html">sqlite3_prepare()</a> and <a href="../c3ref/prepare.html">sqlite3_prepare16()</a>. The use of the
138 new "vX" interface is recommended for new applications but the legacy
139 interface will continue to be supported.</p>
140
141 <p>In the legacy interface, the return value will be either <a href="../rescode.html#busy">SQLITE_BUSY</a>,
142 <a href="../rescode.html#done">SQLITE_DONE</a>, <a href="../rescode.html#row">SQLITE_ROW</a>, <a href="../rescode.html#error">SQLITE_ERROR</a>, or <a href="../rescode.html#misuse">SQLITE_MISUSE</a>.
143 With the "v2" interface, any of the other <a href="../rescode.html">result codes</a> or
144 <a href="../rescode.html#extrc">extended result codes</a> might be returned as well.</p>
145
146 <p><a href="../rescode.html#busy">SQLITE_BUSY</a> means that the database engine was unable to acquire the
147 database locks it needs to do its job. If the statement is a <a href="../lang_transaction.html">COMMIT</a>
148 or occurs outside of an explicit transaction, then you can retry the
149 statement. If the statement is not a <a href="../lang_transaction.html">COMMIT</a> and occurs within an
150 explicit transaction then you should rollback the transaction before
151 continuing.</p>
152
153 <p><a href="../rescode.html#done">SQLITE_DONE</a> means that the statement has finished executing
154 successfully. sqlite3_step() should not be called again on this virtual
155 machine without first calling <a href="../c3ref/reset.html">sqlite3_reset()</a> to reset the virtual
156 machine back to its initial state.</p>
157
158 <p>If the SQL statement being executed returns any data, then <a href="../rescode.html#row">SQLITE_ROW</a>
159 is returned each time a new row of data is ready for processing by the
160 caller. The values may be accessed using the <a href="../c3ref/column_blob.html">column access functions</a>.
161 sqlite3_step() is called again to retrieve the next row of data.</p>
162
163 <p><a href="../rescode.html#error">SQLITE_ERROR</a> means that a run-time error (such as a constraint
164 violation) has occurred. sqlite3_step() should not be called again on
165 the VM. More information may be found by calling <a href="../c3ref/errcode.html">sqlite3_errmsg()</a>.
166 With the legacy interface, a more specific error code (for example,
167 <a href="../rescode.html#interrupt">SQLITE_INTERRUPT</a>, <a href="../rescode.html#schema">SQLITE_SCHEMA</a>, <a href="../rescode.html#corrupt">SQLITE_CORRUPT</a>, and so forth)
168 can be obtained by calling <a href="../c3ref/reset.html">sqlite3_reset()</a> on the
169 <a href="../c3ref/stmt.html">prepared statement</a>. In the "v2" interface,
170 the more specific error code is returned directly by sqlite3_step().</p>
171
172 <p><a href="../rescode.html#misuse">SQLITE_MISUSE</a> means that the this routine was called inappropriately.
173 Perhaps it was called on a <a href="../c3ref/stmt.html">prepared statement</a> that has
174 already been <a href="../c3ref/finalize.html">finalized</a> or on one that had
175 previously returned <a href="../rescode.html#error">SQLITE_ERROR</a> or <a href="../rescode.html#done">SQLITE_DONE</a>. Or it could
176 be the case that the same database connection is being used by two or
177 more threads at the same moment in time.</p>
178
179 <p>For all versions of SQLite up to and including 3.6.23.1, a call to
180 <a href="../c3ref/reset.html">sqlite3_reset()</a> was required after sqlite3_step() returned anything
181 other than <a href="../rescode.html#row">SQLITE_ROW</a> before any subsequent invocation of
182 sqlite3_step(). Failure to reset the prepared statement using
183 <a href="../c3ref/reset.html">sqlite3_reset()</a> would result in an <a href="../rescode.html#misuse">SQLITE_MISUSE</a> return from
184 sqlite3_step(). But after <a href="../releaselog/3_6_23_1.html">version 3.6.23.1</a> (2010-03-26),
185 sqlite3_step() began
186 calling <a href="../c3ref/reset.html">sqlite3_reset()</a> automatically in this circumstance rather
187 than returning <a href="../rescode.html#misuse">SQLITE_MISUSE</a>. This is not considered a compatibility
188 break because any application that ever receives an SQLITE_MISUSE error
189 is broken by definition. The <a href="../compile.html#omit_autoreset">SQLITE_OMIT_AUTORESET</a> compile-time option
190 can be used to restore the legacy behavior.</p>
191
192 <p><b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
193 API always returns a generic error code, <a href="../rescode.html#error">SQLITE_ERROR</a>, following any
194 error other than <a href="../rescode.html#busy">SQLITE_BUSY</a> and <a href="../rescode.html#misuse">SQLITE_MISUSE</a>. You must call
195 <a href="../c3ref/reset.html">sqlite3_reset()</a> or <a href="../c3ref/finalize.html">sqlite3_finalize()</a> in order to find one of the
196 specific <a href="../rescode.html">error codes</a> that better describes the error.
197 We admit that this is a goofy design. The problem has been fixed
198 with the "v2" interface. If you prepare all of your SQL statements
199 using <a href="../c3ref/prepare.html">sqlite3_prepare_v3()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a>
200 or <a href="../c3ref/prepare.html">sqlite3_prepare16_v2()</a> or <a href="../c3ref/prepare.html">sqlite3_prepare16_v3()</a> instead
201 of the legacy <a href="../c3ref/prepare.html">sqlite3_prepare()</a> and <a href="../c3ref/prepare.html">sqlite3_prepare16()</a> interfaces,
202 then the more specific <a href="../rescode.html">error codes</a> are returned directly
203 by sqlite3_step(). The use of the "vX" interfaces is recommended.
204 </p><p>See also lists of
205 <a href="../c3ref/objlist.html">Objects</a>,
206 <a href="../c3ref/constlist.html">Constants</a>, and
207 <a href="../c3ref/funclist.html">Functions</a>.</p>
208