source: project/release/3/sqlite3/tags/2.0.4/sqlite3.html @ 8020

Last change on this file since 8020 was 8020, checked in by Kon Lovett, 12 years ago

Bug fix & new procs.

File size: 30.7 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2<!-- Generated by eggdoc Revision: 1.20  -->
3<html>
4<head>
5<title>Eggs Unlimited - sqlite3</title><style type="text/css"> <!--
6      CODE {
7            color: #666666;
8          }
9/*   DT.definition EM { font-weight: bold; font-style: normal; } */
10
11     DT.definition { 
12                   background: #eee;
13                   color: black;
14                   padding: 0.2em 1em 0.2em 0.7em;
15                   margin-left: 0.2em;
16border: 1px solid #bbc;
17                   font-family: "Andale Mono", monospace;
18                   /* font-size: 1.2em; */
19                   
20                 }
21     DD {
22                   margin-top: 0.8em;
23                   margin-bottom: 0.8em;
24     }
25     DIV.subsection {
26                    border-top: 1px solid #448;
27                    padding-left: 1em;
28                    margin-bottom: 1.2em;
29     }
30     DIV.subsubsection {
31                    border-top: 1px dotted #99c;
32                    /* border-left: 1px solid #99c; */
33                    padding-left: 1em;
34                    margin-bottom: 1.2em;
35     }
36     DIV.subsubsubsection {
37                    border-top: 1px solid #ddf;
38                    padding-left: 1em;
39                    margin-bottom: 1.2em;
40     }
41
42         DIV.section {
43                 margin-bottom: 1.5em;
44         }
45         a:link {
46                 color: #336;
47         }
48         a:visited { color: #666; }
49         a:active  { color: #966; }
50         a:hover   { color: #669; }
51         body { margin: 0; padding: 0; background: #fff; color: #000; font: 9pt "Lucida Grande", "Verdana", sans-serif; }
52         H2 {
53                 background: #336;
54                 color: #fff;
55                 padding-top: 0.5em;
56                 padding-bottom: 0.5em;
57                 padding-left: 16px;
58                 margin: 0 0 1em 0;
59        }
60        UL LI {
61                list-style: none;
62        }
63        TT {
64                font-family: "Andale Mono", monospace;
65                /* font-size: 1.2em; */
66        }
67        H3 {
68                color: #113;
69                margin-bottom: 0.5em;
70        }
71        H4, H5, H6 {
72                color: #113;
73                margin-bottom: 1.0em;
74        }
75        H5 {
76                font-weight: normal;
77                font-style: italic;
78                font-size: 100%;
79                margin-top: 1.2em;
80        }
81        H6 {
82                font-weight: bold;
83                font-size: 85%;
84                margin-top: 1.2em;
85        }
86     DIV#eggheader {
87         text-align: center;
88                 float: right;
89                 margin-right: 2em;
90     }
91     DIV#header IMG {
92            /* display: block; margin-left: auto; margin-right: auto;  */
93            /* float: right; */
94            border: none;  /* firefox */
95     }
96     DIV#footer {
97                background: #bbd;
98                padding: 0.7em ;
99                border-top: 1px solid #cce;
100     }
101     DIV#footer hr {
102                display: none;
103     }
104     DIV#footer a {
105                float: left;
106     }
107     DIV#revision-history {
108         float: right;
109     }
110     
111     DIV#body {
112                 margin: 1em 1em 1em 16px;
113         }
114
115     DIV#examples PRE {
116       background: #eef;
117       padding: 0.1em;
118       border: 1px solid #aac;
119     }
120     PRE#license, DIV#examples PRE {
121       padding: 0.5em;
122     }
123     DIV#examples PRE {
124       /* font-size: 85%; */
125     }
126     PRE { font-family: "Andale Mono", monospace; }
127     TABLE {
128       background: #eef;
129       padding: 0.2em;
130       border: 1px solid #aac;
131       border-collapse: collapse;
132       width: 100%;
133     }
134     TABLE.symbol-table TD.symbol {
135          width: 15em;
136          font-family: "Andale Mono", monospace;
137          /* font-size: 1.2em; */
138     }
139     TH {
140       text-align: left;
141       border-bottom: 1px solid #aac;
142       padding: 0.25em 0.5em 0.25em 0.5em;
143     } 
144     TD { padding: 0.25em 0.5em 0.25em 0.5em; }
145     --></style></head>
146<body>
147<div id="header">
148<h2>sqlite3</h2>
149<div id="eggheader"><a href="index.html">
150<img src="egg.jpg" alt="[Picture of an egg]" /></a></div></div>
151<div id="body">
152<div class="section">
153<h3>Description</h3>
154<p>Bindings to version 3.x of the SQLite API.</p></div>
155<div class="section">
156<h3>Author</h3><a href="http://www.chust.org/">Thomas Chust</a></div>
157<div class="section">
158<h3>Usage</h3><tt>(require-extension sqlite3)</tt></div>
159<div class="section">
160<h3>Download</h3><a href="sqlite3.egg">sqlite3.egg</a></div>
161<div class="section">
162<h3>Requires</h3>
163<ul>
164<li>synch</li>
165<li>tinyclos</li>
166<li>easyffi</li>
167<li>miscmacros</li></ul></div>
168<div class="section">
169<h3>Documentation</h3>
170<p>The API of SQLite changed significantly from version 2.x to 3.x. These are new bindings to the modified API, which are reasonably complete -- most procedures that take callback arguments are missing, though.</p>
171<p>For in-depth information on the functionality of the routines and general information you should consult the <a href="http://www.sqlite.org/">SQLite documentation</a> as well as this manual.</p>
172<div class="subsection">
173<h4>Exceptions</h4>
174<p>Unless otherwise indicated, all procedures and methods in this egg may throw an exception of the kind <tt>(exn sqlite3)</tt> if something goes wrong. This exception will contain a <tt>status</tt> property indicating the return value of the operation that failed:
175<table>
176<tr>
177<th>Symbol</th>
178<th>Meaning</th></tr>
179<tr>
180<td><tt>error</tt></td>
181<td>SQL error or missing database </td></tr>
182<tr>
183<td><tt>internal</tt></td>
184<td>An internal logic error in SQLite </td></tr>
185<tr>
186<td><tt>permission</tt></td>
187<td>Access permission denied </td></tr>
188<tr>
189<td><tt>abort</tt></td>
190<td>Callback routine requested an abort </td></tr>
191<tr>
192<td><tt>busy</tt></td>
193<td>The database file is locked </td></tr>
194<tr>
195<td><tt>locked</tt></td>
196<td>A table in the database is locked </td></tr>
197<tr>
198<td><tt>no-memory</tt></td>
199<td>A malloc() failed </td></tr>
200<tr>
201<td><tt>read-only</tt></td>
202<td>Attempt to write a readonly database </td></tr>
203<tr>
204<td><tt>interrupt</tt></td>
205<td>Operation terminated by sqlite-interrupt() </td></tr>
206<tr>
207<td><tt>io-error</tt></td>
208<td>Some kind of disk I/O error occurred </td></tr>
209<tr>
210<td><tt>corrupt</tt></td>
211<td>The database disk image is malformed </td></tr>
212<tr>
213<td><tt>not-found</tt></td>
214<td>(Internal Only) Table or record not found </td></tr>
215<tr>
216<td><tt>full</tt></td>
217<td>Insertion failed because database is full </td></tr>
218<tr>
219<td><tt>cant-open</tt></td>
220<td>Unable to open the database file </td></tr>
221<tr>
222<td><tt>protocol</tt></td>
223<td>Database lock protocol error </td></tr>
224<tr>
225<td><tt>empty</tt></td>
226<td>(Internal Only) Database table is empty </td></tr>
227<tr>
228<td><tt>schema</tt></td>
229<td>The database schema changed </td></tr>
230<tr>
231<td><tt>too-big</tt></td>
232<td>Too much data for one row of a table </td></tr>
233<tr>
234<td><tt>constraint</tt></td>
235<td>Abort due to contraint violation </td></tr>
236<tr>
237<td><tt>mismatch</tt></td>
238<td>Data type mismatch </td></tr>
239<tr>
240<td><tt>misuse</tt></td>
241<td>Library used incorrectly </td></tr>
242<tr>
243<td><tt>no-lfs</tt></td>
244<td>Uses OS features not supported on host </td></tr>
245<tr>
246<td><tt>authorization</tt></td>
247<td> Authorization denied</td></tr>
248<tr>
249<td><tt>done</tt></td>
250<td><tt>sqlite3:step!</tt> has finished executing, so no further data is ready</td></tr></table></p></div>
251<div class="subsection">
252<h4>Classes</h4>
253<dl>
254<dt class="definition"><strong>class:</strong> &lt;sqlite3:database&gt;
255<br /><strong>class:</strong> &lt;sqlite3:statement&gt;</dt>
256<dd>
257<p>These classes are derived from <tt>&lt;c++-object&gt;</tt>. They hold a pointer to the underlying C-structure in their <tt>this</tt> slot.</p>
258<p><tt>&lt;sqlite3:statement&gt;</tt> also has a <tt>database</tt> slot pointing to the database object it belongs to.</p></dd></dl></div>
259<div class="subsection">
260<h4>Managing databases</h4>
261<dl>
262<dt class="definition"><strong>procedure:</strong> (sqlite3:open (path &lt;string&gt;)) =&gt; &lt;sqlite3:database&gt;</dt>
263<dd>
264<p>Opens the indicated database file and returns a <tt>&lt;sqlite3:database&gt;</tt> object for it.</p>
265<p>The given path is subject to the same special expansion as paths passed to
266<p>open-input-file</p> and similar procedures.</p></dd>
267<dt class="definition"><strong>method:</strong> (sqlite3:define-collation (db &lt;sqlite3:database&gt;) (name &lt;string&gt;)) =&gt; &lt;void&gt;
268<br /><strong>method:</strong> (sqlite3:define-collation (db &lt;sqlite3:database&gt;) (name &lt;string&gt;) (proc &lt;procedure-class&gt;)) =&gt; &lt;void&gt;</dt>
269<dd>
270<p>If <tt>proc</tt> is given, registers a new collation sequence identified by <tt>name</tt> for use in the context of database handle <tt>db</tt>. If no procedure is passed, the collation sequence with the given name is removed.</p>
271<p><tt>proc</tt> should have the signature <tt>(proc (a &lt;string&gt;) (b &lt;string&gt;)) =&gt; &lt;exact&gt;</tt>. It should return a negative number if <tt>a</tt> sorts before <tt>b</tt>, a positive number if <tt>b</tt> sorts before <tt>a</tt> and zero if <tt>a</tt> and <tt>b</tt> are equal.</p>
272<p>As <tt>proc</tt> will be called in a callback context from within <tt>sqlite3:step!</tt>, safety measures are installed to avoid throwing any exceptions, invoking continuations or returning invalid values from it. Attempts to do so will result in a <tt>0</tt> return value and warning messages.</p></dd>
273<dt class="definition"><strong>method:</strong> (sqlite3:define-function (db &lt;sqlite3:database&gt;) (name &lt;string&gt;) (n &lt;exact&gt;) (proc &lt;procedure-class&gt;)) =&gt; &lt;void&gt;
274<br /><strong>method:</strong> (sqlite3:define-function (db &lt;sqlite3:database&gt;) (name &lt;string&gt;) (n &lt;exact&gt;) (step-proc &lt;procedure-class&gt;) (seed &lt;top&gt;) #!optional ((final-proc &lt;procedure-class&gt;) identity)) =&gt; &lt;void&gt;</dt>
275<dd>
276<p>If <tt>proc</tt> is given, registers a new SQL function identified by <tt>name</tt> for use in the context of database handle <tt>db</tt>. If <tt>step-proc</tt> and <tt>final-proc</tt> are given, the new function becomes an aggregate function. Once registered, functions cannot be deleted.</p>
277<p><tt>n</tt> is the number of parameters the new SQL function takes or <tt>-1</tt> to allow any number of arguments.</p>
278<p><tt>proc</tt> should have the signature <tt>(proc . params) =&gt; &lt;top&gt;</tt>. It is called with the <tt>n</tt> parameters given to the SQL function converted into Scheme objects like by <tt>sqlite3:column-data</tt>. The return value is converted into an SQLite3 data object like by <tt>sqlite3:bind!</tt>. A return value of <tt>(void)</tt> corresponds to <tt>NULL</tt> in SQLite3.</p>
279<p><tt>step-proc</tt> should have the signature <tt>(step-proc (seed &lt;top&gt;) . params) =&gt; &lt;top&gt;</tt>. It is called with the parameters given to the SQL function for every row being processed. The seed value passed is initially the one given as an argument to <tt>sqlite3:define-function</tt>; for subsequent calls it is the last value returned by <tt>step-proc</tt> and after completion of <tt>final-proc</tt> it will be the initial value again.</p>
280<p><tt>final-proc</tt> should have the signature <tt>(final-proc (seed &lt;top&gt;)) =&gt; &lt;top&gt;</tt> and transforms the last seed value into the value to be returned from the aggregate function.</p>
281<p>As <tt>proc</tt>, <tt>step-proc</tt> and <tt>final-proc</tt> will be called in a callback context from within <tt>sqlite3:step!</tt>, safety measures are installed to avoid throwing any exceptions, invoking continuations or returning invalid values from them. Attempts to do such things will result in <tt>NULL</tt> return values and warning messages.</p></dd>
282<dt class="definition"><strong>procedure:</strong> (sqlite3:set-busy-timeout! (db &lt;sqlite3:database&gt;) #!optional ((ms &lt;exact&gt;) 0)) =&gt; &lt;void&gt;</dt>
283<dd>
284<p>Installs a busy handler that waits at least the specified amount of milliseconds for locks on the given database. If <tt>(&lt;= ms 0)</tt> though, all busy handlers for the database are uninstalled.</p></dd>
285<dt class="definition"><strong>procedure:</strong> (sqlite3:interrupt! (db &lt;sqlite3:database&gt;)) =&gt; &lt;void&gt;</dt>
286<dd>
287<p>Cancels any running database operation as soon as possible.</p>
288<p>This function is always successful and never throws an exception.</p></dd>
289<dt class="definition"><strong>procedure:</strong> (sqlite3:auto-committing? (db &lt;sqlite3:database&gt;)) =&gt; &lt;bool&gt;</dt>
290<dd>
291<p>Checks whether the database is currently in auto committing mode, i.e. no transaction is currently active.</p>
292<p>This function always returns a state and never throws an exception.</p></dd>
293<dt class="definition"><strong>procedure:</strong> (sqlite3:changes (db &lt;sqlite3:database&gt;) #!optional ((total &lt;bool&gt;) #f)) =&gt; &lt;number&gt;</dt>
294<dd>
295<p>Returns the number of rows changed by the last statement (if <tt>(not total)</tt>) or since the database was opened (if <tt>total</tt>).</p>
296<p>This function always returns a count and never throws an exception.</p></dd>
297<dt class="definition"><strong>procedure:</strong> (sqlite3:last-insert-rowid (db &lt;sqlite3:database&gt;)) =&gt; &lt;number&gt;</dt>
298<dd>
299<p>Returns the row ID of the last row inserted in <tt>db</tt>.</p>
300<p>This function always returns a number and never throws an exception.</p></dd>
301<dt class="definition"><strong>method:</strong> (sqlite3:finalize! (db &lt;sqlite3:database&gt;)) =&gt; &lt;void&gt;</dt>
302<dd>
303<p>Closes the given database.</p></dd></dl></div>
304<div class="subsection">
305<h4>Managing statements</h4>
306<dl>
307<dt class="definition"><strong>procedure:</strong> (sqlite3:prepare (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;)) =&gt; &lt;sqlite3:statement&gt;, &lt;string&gt;</dt>
308<dd>
309<p>Compiles the first SQL statement in <tt>sql</tt> and returns a <tt>&lt;sqlite3:statement&gt;</tt> and the rest of <tt>sql</tt>, which was not compiled (or an empty string).</p></dd>
310<dt class="definition"><strong>procedure:</strong> (sqlite3:repair! (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;void&gt;</dt>
311<dd>
312<p>Recompiles the SQL statement used to create <tt>stmt</tt>, transfers all existing bindings from the old statement handle to the new one and destructively modifies <tt>stmt</tt> to point to the new statement handle.</p>
313<p>If the operation is successful, the old handle is finalized, in case of error, the new handle is finalized and the old one stays untouched.</p>
314<p>Usually you should not have to call this routine by hand. It is invoked by <tt>sqlite3:step!</tt> to automagically repair a stale statement handle after a database schema change.</p></dd>
315<dt class="definition"><strong>procedure:</strong> (sqlite3:column-count (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;exact&gt;</dt>
316<dd>
317<p>Can be applied to any statement and returns the number of columns it will return as results.</p>
318<p>This procedure always succeeds and never throws an exception.</p></dd>
319<dt class="definition"><strong>procedure:</strong> (sqlite3:column-name (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;string&gt;</dt>
320<dd>
321<p>Can be applied to any statement and returns the name of the column number <tt>i</tt> (counting from 0) as a string or <tt>#f</tt> if the column has no name.</p>
322<p>This procedure always succeeds and never throws an exception.</p></dd>
323<dt class="definition"><strong>procedure:</strong> (sqlite3:column-declared-type (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;string&gt;</dt>
324<dd>
325<p>Can be applied to any statement and returns the declared type (as given in the <tt>CREATE</tt> statement) of the column number <tt>i</tt> (counting from 0) as a string or <tt>#f</tt> if the column has no declared type.</p>
326<p>This procedure always succeeds and never throws an exception.</p></dd>
327<dt class="definition"><strong>procedure:</strong> (sqlite3:bind-parameter-count (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;exact&gt;</dt>
328<dd>
329<p>Can be applied to any statement and returns the number of free parameters that can be bound in the statement.</p>
330<p>This procedure always succeeds and never throws an exception.</p></dd>
331<dt class="definition"><strong>procedure:</strong> (sqlite3:bind-parameter-index (stmt &lt;sqlite3:statement&gt;) (name &lt;string&gt;)) =&gt; &lt;exact&gt;</dt>
332<dd>
333<p>Can be applied to any statement and returns the index of the bindable parameter called <tt>name</tt> or <tt>#f</tt> if no such parameter exists.</p>
334<p>This procedure always succeeds and never throws an exception.</p></dd>
335<dt class="definition"><strong>procedure:</strong> (sqlite3:bind-parameter-name (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;string&gt;</dt>
336<dd>
337<p>Can be applied to any statement and returns the name of the bindable parameter number <tt>i</tt> (counting from 0) or <tt>#f</tt> if no such parameter exists or the parameter has no name.</p>
338<p>This procedure always succeeds and never throws an exception.</p></dd>
339<dt class="definition"><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;void&gt;
340<br /><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;) (v &lt;void&gt;)) =&gt; &lt;void&gt;
341<br /><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;) (v &lt;exact&gt;)) =&gt; &lt;void&gt;
342<br /><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;) (v &lt;number&gt;)) =&gt; &lt;void&gt;
343<br /><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;) (v &lt;string&gt;)) =&gt; &lt;void&gt;
344<br /><strong>method:</strong> (sqlite3:bind! (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;) (v &lt;blob&gt;)) =&gt; &lt;void&gt;</dt>
345<dd>
346<p>Can be applied to any statement to bind its free parameter number <tt>i</tt> (counting from 0) to the given value. Scheme types of the value map to SQLite types as follows:
347<table>
348<tr>
349<th>Scheme type</th>
350<th>SQLite type</th></tr>
351<tr>
352<td>none</td>
353<td><tt>null</tt></td></tr>
354<tr>
355<td><tt>&lt;sqlite3:null-value&gt;</tt></td>
356<td><tt>null</tt></td></tr>
357<tr>
358<td><tt>&lt;exact&gt;</tt></td>
359<td><tt>integer</tt></td></tr>
360<tr>
361<td><tt>&lt;number&gt;</tt></td>
362<td><tt>float</tt></td></tr>
363<tr>
364<td><tt>&lt;string&gt;</tt></td>
365<td><tt>text</tt></td></tr>
366<tr>
367<td><tt>&lt;blob&gt;</tt></td>
368<td><tt>blob</tt></td></tr></table></p>
369<p>Unless there is internal trouble in SQLite3, this method should always succeeds and never throw an exception. For invalid parameter indices the method just silently does nothing.</p></dd>
370<dt class="definition"><strong>procedure:</strong> (sqlite3:bind-parameters! (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;void&gt;</dt>
371<dd>
372<p>Binds the statement's free parameters.</p></dd>
373<dt class="definition"><strong>procedure:</strong> (sqlite3:step! (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;boolean&gt;</dt>
374<dd>
375<p>Single-steps the execution of <tt>stmt</tt> and returns <tt>#t</tt> if a result row was produced, <tt>#f</tt> if no further results are available as the statement has been stepped through. This procedure must be called at least once before any results can be retrieved from the statement.</p></dd>
376<dt class="definition"><strong>procedure:</strong> (sqlite3:column-type (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;symbol&gt;</dt>
377<dd>
378<p>Can be applied to a statement that has just been stepped (otherwise it returns <tt>#f</tt>) and returns the SQLite type of the result column number <tt>i</tt> (counting from 0) as a symbol.</p>
379<p>The return value can be one of the symbols <tt>null</tt>, <tt>integer</tt>, <tt>float</tt>, <tt>text</tt> or <tt>blob</tt>.</p>
380<p>This procedure always succeeds and never throws an exception.</p></dd>
381<dt class="definition"><strong>procedure:</strong> (sqlite3:column-data (stmt &lt;sqlite3:statement&gt;) (i &lt;exact&gt;)) =&gt; &lt;void | exact | number | string | blob&gt;</dt>
382<dd>
383<p>Can be applied to a statement that has just been stepped. Consults <tt>sqlite3:column-type</tt> to determine the type of the indicated column and to return its data as an appropriate scheme object.</p>
384<p>See <tt>sqlite3:bind!</tt> for the mapping between Scheme and SQLite data types. Columns of type <tt>null</tt> are returned as <tt>&lt;sqlite3:null-value&gt;</tt>. Also keep in mind that CHICKEN's <tt>&lt;exact&gt;</tt> datatype can only hold a subset of the values an SQLite <tt>integer</tt> can store. Large integer values may therefore be returned as floating point numbers from the database, but they will still be of class <tt>&lt;integer&gt;</tt>.</p>
385<p>This procedure always succeeds and never throws an exception.</p></dd>
386<dt class="definition"><strong>procedure:</strong> (sqlite3:reset! (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;void&gt;</dt>
387<dd>
388<p>Can be applied to any statement and resets it such that execution using <tt>sqlite3:step!</tt> will perform all operations of the statement again.</p></dd>
389<dt class="definition"><strong>method:</strong> (sqlite3:finalize! (stmt &lt;sqlite3:statement&gt;)) =&gt; &lt;void&gt;</dt>
390<dd>
391<p>Must be applied to every statement to free its resources and discard it.</p>
392<p><tt>sqlite3:close</tt> will not be able to close a database that has associated unfinalized statements.</p></dd></dl></div>
393<div class="subsection">
394<h4>Simple statement interface</h4>
395<dl>
396<dt class="definition"><strong>procedure:</strong> (sqlite3:call-with-temporary-statements (proc &lt;procedure-class&gt;) (db &lt;sqlite3:database&gt;) . sqls) =&gt; &lt;top&gt;</dt>
397<dd>
398<p>Compiles the SQL sources in <tt>sqls</tt> into statements in the context of <tt>db</tt>, applies <tt>proc</tt> to these statements and returns <tt>proc</tt>'s result. The statements are created and finalized in <tt>dynamic-wind</tt> entry and exit blocks around the application of <tt>proc</tt>.</p></dd>
399<dt class="definition"><strong>method:</strong> (sqlite3:exec (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;void&gt;
400<br /><strong>method:</strong> (sqlite3:exec (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;void&gt;</dt>
401<dd>
402<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and executes the statement ignoring possible results from it.</p></dd>
403<dt class="definition"><strong>method:</strong> (sqlite3:update (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;exact&gt;
404<br /><strong>method:</strong> (sqlite3:update (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;exact&gt;</dt>
405<dd>
406<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and executes the specified statement ignoring possible results from it, returning the result of applying <tt>sqlite3:changes</tt> to the affected database after the execution of the statement instead.</p></dd>
407<dt class="definition"><strong>method:</strong> (sqlite3:first-result (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;void | exact | number | string | blob&gt;
408<br /><strong>method:</strong> (sqlite3:first-result (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;void | exact | number | string | blob&gt;</dt>
409<dd>
410<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and single-steps the statement once returning the value of the first column in the first result row. Resets the statement again just before returning.</p>
411<p>If the given statement does not yield any results, an <tt>(exn sqlite3)</tt> is thrown with the <tt>status</tt>-property set to <tt>done</tt>.</p></dd>
412<dt class="definition"><strong>method:</strong> (sqlite3:first-row (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;list&gt;
413<br /><strong>method:</strong> (sqlite3:first-row (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;list&gt;</dt>
414<dd>
415<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and single-steps the statement once returning all columns in the first result row as a list.</p>
416<p>If the given statement does not yield any results, an <tt>(exn sqlite3)</tt> is thrown with the <tt>status</tt>-property set to <tt>done</tt>.</p></dd>
417<dt class="definition"><strong>method:</strong> (sqlite3:fold-row (proc &lt;procedure-class&gt;) (stmt &lt;sqlite3:statement&gt;) initial . params) =&gt; &lt;list&gt;
418<br /><strong>method:</strong> (sqlite3:fold-row (proc &lt;procedure-class&gt;) (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) initial . params) =&gt; &lt;list&gt;</dt>
419<dd>
420<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and executes it step by step. After each step, the column values of the current result row are retrieved and <tt>proc</tt> is applied to the current folded value and the column values. The result of the application becomes the new folded value.</p></dd>
421<dt class="definition"><strong>method:</strong> (sqlite3:for-each-row (proc &lt;procedure-class&gt;) (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;void&gt;
422<br /><strong>method:</strong> (sqlite3:for-each-row (proc &lt;procedure-class&gt;) (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;void&gt;</dt>
423<dd>
424<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and executes it step by step. After each step, the column values of the current result row are retrieved and <tt>proc</tt> is applied to them. The results of this application are discarded.</p></dd>
425<dt class="definition"><strong>method:</strong> (sqlite3:map-row (proc &lt;procedure-class&gt;) (stmt &lt;sqlite3:statement&gt;) . params) =&gt; &lt;list&gt;
426<br /><strong>method:</strong> (sqlite3:map-row (proc &lt;procedure-class&gt;) (db &lt;sqlite3:database&gt;) (sql &lt;string&gt;) . params) =&gt; &lt;list&gt;</dt>
427<dd>
428<p>(Compiles the given SQL), resets the statement, binds the statement's free parameters and executes it step by step. After each step, the column values of the current result row are retrieved and <tt>proc</tt> is applied to them. The results of these applications are collected into a list.</p></dd></dl></div>
429<div class="subsection">
430<h4>Utility functions</h4>
431<dl>
432<dt class="definition"><strong>procedure:</strong> (sqlite3:with-transaction (db &lt;sqlite3:database&gt;) (thunk &lt;procedure-class&gt;) #!optional ((type &lt;symbol&gt;) 'deferred)) =&gt; &lt;void&gt;</dt>
433<dd>
434<p>Runs <tt>thunk</tt> within the scope of a transaction on the dataase <tt>db</tt>.</p>
435<p>The transaction is committed upon exit from <tt>thunk</tt> if <tt>thunk</tt> returns a true value. If <tt>thunk</tt> returns a false value or throws an exception, the transaction is rolled back.</p>
436<p>The <tt>type</tt> of the transaction can be specified as one of the symbols <tt>deferred</tt>, <tt>immediate</tt> or <tt>exclusive</tt>.</p></dd>
437<dt class="definition"><strong>procedure:</strong> (sqlite3:complete? (sql &lt;string&gt;)) =&gt; &lt;boolean&gt;</dt>
438<dd>
439<p>Checks whether <tt>sql</tt> comprises at least one complete SQL statement.</p></dd>
440<dt class="definition"><strong>procedure:</strong> (sqlite3:library-version) =&gt; &lt;string&gt;</dt>
441<dd>
442<p>Returns a string identifying the version of SQLite in use.</p></dd>
443<dt class="definition"><strong>procedure:</strong> (sqlite3:null-value? &lt;object&gt;) =&gt; &lt;boolean&gt;</dt>
444<dd>
445<p>Is the <tt>&lt;object&gt;</tt> a &lt;sqlite3:null-value&gt;?</p>
446<p>The &lt;sqlite3:null-value&gt; is compatible with the &quot;sql-null&quot; egg. The default &quot;sql-null&quot; egg function <code>(sql-null)</code> = the &lt;sqlite3:null-value&gt;. But to ensure equality - <code>(define sql-null sqlite3:null)</code>.</p></dd></dl></div></div>
447<div class="section">
448<h3>Version</h3>
449<ul>
450<li>2.0.4 Added <code>sqlite3:fold-row</code> &amp; <code>sqlite3:bind-parameters!</code>. Fix for introduced bug in <code>sqlite3:changes</code>. [Kon Lovett]</li>
451<li>2.0.3 Added <code>sqlite3:null-value</code>, <code>sqlite3:null-value?</code>, and <code>sqlite3:null</code>. [Kon Lovett]</li>
452<li>2.0.2 Use of extended <tt>define-foreign-enum</tt>. Removed deprecated <tt>pointer</tt> use. [Kon Lovett]</li>
453<li>2.0.1 Deprecated <tt>&lt;byte-vector&gt;</tt>, use <tt>&lt;blob&gt;</tt> [Kon Lovett]</li>
454<li>2.0.0 Now using <tt>(void)</tt> to represent <tt>NULL</tt></li>
455<li>1.5.9 dll extension not used anymore in newer chickens [felix]</li>
456<li>1.5.8 Update for synch 1.3 [Kon Lovett]</li>
457<li>1.5.7 Updated compiler flags to pull in tinyclos and easyffi</li>
458<li>1.5.6 Replaced deprecated synch operations [Kon Lovett]</li>
459<li>1.5.5 Correction in the documentation, added sqlite3:with-transaction</li>
460<li>1.5.4 Typo fixed thanks to the new imports checking code</li>
461<li>1.5.3 Proper multithreading locks for the callback code</li>
462<li>1.5.2 Code cleanups</li>
463<li>1.5.1 Potential memory leaks removed</li>
464<li>1.5.0 Support for user defined collation sequences and functions has been added</li>
465<li>1.4.0 Stale statement handles due to schema changes are now automagically recompiled to keep them valid</li>
466<li>1.3.1 Several small routines added</li>
467<li>1.3.0 Special hacks removed as CVS version of SQLite3.3.4 has been fixed</li>
468<li>1.2.0 Special hacks to deal with &quot;valid&quot; <tt>NULL</tt> statements</li>
469<li>1.1.4 Tightened security measures against <tt>#f</tt> pointers</li>
470<li>1.1.3 Integers not fitting in a fixnum are now read correctly from the database [thanks to Zbigniew]</li>
471<li>1.1.2 Setup file patched to call compiled output .dll on Windows</li>
472<li>1.1.1 All procedures now reset prepared statements where you would do that by hand anyway</li>
473<li>1.1.0 Promoted <tt>sqlite3:call-with-temporary-statement</tt> to <tt>sqlite3:call-with-temporary-statements</tt> and fixed a really stupid coding mistake in <tt>sqlite3:changes</tt></li>
474<li>1.0.3 Fixed C compiler warnings</li>
475<li>1.0.2 Added a typecheck for increased safety</li>
476<li>1.0.1 Fixed type mistakes in the source</li>
477<li>1.0.0 Initial release</li></ul></div>
478<div class="section">
479<h3>License</h3>
480<pre id="license">Copyright (c) 2005, Thomas Chust &lt;chust@web.de&gt;.  All rights reserved.
481
482Redistribution and use in source and binary forms, with or without
483modification, are permitted provided that the following conditions are met:
484
485  Redistributions of source code must retain the above copyright notice,
486  this list of conditions and the following disclaimer. Redistributions in
487  binary form must reproduce the above copyright notice, this list of
488  conditions and the following disclaimer in the documentation and/or
489  other materials provided with the distribution. Neither the name of the
490  author nor the names of its contributors may be used to endorse or
491  promote products derived from this software without specific prior
492  written permission.
493
494THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS
495IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
496THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
497PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
498CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
499EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
500PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
501PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
502LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
503NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
504SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</pre></div></div>
505<div id="footer">
506<hr /><a href="index.html">&lt; Egg index</a>
507<div id="revision-history">$Revision$ $Date$</div>&nbsp;</div></body></html>
Note: See TracBrowser for help on using the repository browser.