/usr/share/doc/racket/db/query-api.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>3 Queries</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">DB:<span class="mywbr"> </span> Database Connectivity</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="using-db.html" class="tocviewlink" data-pltdoc="x">Using Database Connections</a></td></tr><tr><td align="right">2 </td><td><a href="connect.html" class="tocviewlink" data-pltdoc="x">Connections</a></td></tr><tr><td align="right">3 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Queries</a></td></tr><tr><td align="right">4 </td><td><a href="sql-types.html" class="tocviewlink" data-pltdoc="x">SQL Types and Conversions</a></td></tr><tr><td align="right">5 </td><td><a href="util.html" class="tocviewlink" data-pltdoc="x">Utilities</a></td></tr><tr><td align="right">6 </td><td><a href="notes.html" class="tocviewlink" data-pltdoc="x">Notes</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">►</a></td><td>3 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Queries</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">3.1 </td><td><a href="#%28part._query-statements%29" class="tocviewlink" data-pltdoc="x">Statements</a></td></tr><tr><td align="right">3.2 </td><td><a href="#%28part._.Simple_.Queries%29" class="tocviewlink" data-pltdoc="x">Simple Queries</a></td></tr><tr><td align="right">3.3 </td><td><a href="#%28part._.General_.Query_.Support%29" class="tocviewlink" data-pltdoc="x">General Query Support</a></td></tr><tr><td align="right">3.4 </td><td><a href="#%28part._.Prepared_.Statements%29" class="tocviewlink" data-pltdoc="x">Prepared Statements</a></td></tr><tr><td align="right">3.5 </td><td><a href="#%28part._transactions%29" class="tocviewlink" data-pltdoc="x">Transactions</a></td></tr><tr><td align="right">3.6 </td><td><a href="#%28part._.S.Q.L_.Errors%29" class="tocviewlink" data-pltdoc="x">SQL Errors</a></td></tr><tr><td align="right">3.7 </td><td><a href="#%28part._.Database_.Catalog_.Information%29" class="tocviewlink" data-pltdoc="x">Database Catalog Information</a></td></tr><tr><td align="right">3.8 </td><td><a href="#%28part._.Creating_.New_.Kinds_of_.Statements%29" class="tocviewlink" data-pltdoc="x">Creating New Kinds of Statements</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">3.1<tt> </tt></span><a href="#%28part._query-statements%29" class="tocsubseclink" data-pltdoc="x">Statements</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">statement?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.2<tt> </tt></span><a href="#%28part._.Simple_.Queries%29" class="tocsubseclink" data-pltdoc="x">Simple Queries</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-exec%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>exec</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-rows%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>rows</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>list</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-row%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>row</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-row%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>maybe-<wbr></wbr>row</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>value</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-value%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query-<wbr></wbr>maybe-<wbr></wbr>value</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in-<wbr></wbr>query</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.3<tt> </tt></span><a href="#%28part._.General_.Query_.Support%29" class="tocsubseclink" data-pltdoc="x">General Query Support</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._simple-result%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">simple-<wbr></wbr>result</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">rows-<wbr></wbr>result</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">query</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">group-<wbr></wbr>rows</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-~3edict%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">rows-<wbr></wbr>>dict</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.4<tt> </tt></span><a href="#%28part._.Prepared_.Statements%29" class="tocsubseclink" data-pltdoc="x">Prepared Statements</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prepare</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prepared-<wbr></wbr>statement?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement-parameter-types%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prepared-<wbr></wbr>statement-<wbr></wbr>parameter-<wbr></wbr>types</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement-result-types%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prepared-<wbr></wbr>statement-<wbr></wbr>result-<wbr></wbr>types</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">bind-<wbr></wbr>prepared-<wbr></wbr>statement</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement-binding~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">statement-<wbr></wbr>binding?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">virtual-<wbr></wbr>statement</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">virtual-<wbr></wbr>statement?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.5<tt> </tt></span><a href="#%28part._transactions%29" class="tocsubseclink" data-pltdoc="x">Transactions</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">start-<wbr></wbr>transaction</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._commit-transaction%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">commit-<wbr></wbr>transaction</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rollback-transaction%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">rollback-<wbr></wbr>transaction</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-transaction~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in-<wbr></wbr>transaction?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._needs-rollback~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">needs-<wbr></wbr>rollback?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">call-<wbr></wbr>with-<wbr></wbr>transaction</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.6<tt> </tt></span><a href="#%28part._.S.Q.L_.Errors%29" class="tocsubseclink" data-pltdoc="x">SQL Errors</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">exn:<span class="mywbr"> </span>fail:<span class="mywbr"> </span>sql</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.7<tt> </tt></span><a href="#%28part._.Database_.Catalog_.Information%29" class="tocsubseclink" data-pltdoc="x">Database Catalog Information</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._list-tables%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">list-<wbr></wbr>tables</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._table-exists~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">table-<wbr></wbr>exists?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3.8<tt> </tt></span><a href="#%28part._.Creating_.New_.Kinds_of_.Statements%29" class="tocsubseclink" data-pltdoc="x">Creating New Kinds of Statements</a></td></tr><tr><td><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prop~3astatement%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">prop:<span class="mywbr"> </span>statement</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="connect.html" title="backward to "2 Connections"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "DB: Database Connectivity"" data-pltdoc="x">up</a> <a href="sql-types.html" title="forward to "4 SQL Types and Conversions"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""query-api"">3<tt> </tt><a name="(part._query-api)"></a>Queries</h3><p>This library provides a high-level functional query API,
unlike many other database libraries, which present a stateful,
iteration-based interface to queries. When a query function is
invoked, it either returns a result or, if the query caused an error,
raises an exception. Different query functions impose different
constraints on the query results and offer different mechanisms for
processing the results.</p><p><div class="SIntrapara"><span style="font-weight: bold">Errors</span><span class="hspace"> </span> In most cases, a query error does not cause the
connection to be disconnected. Specifically, the following kinds of
errors should never cause a connection to be disconnected:
</div><div class="SIntrapara"><ul><li><p>SQL syntax errors, such as references to undefined tables,
columns, or operations, etc</p></li><li><p>SQL runtime errors, such as integrity constraint violations</p></li><li><p>violations of a specialized query function’s expectations, such
as using <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span> with a query that returns multiple
columns</p></li><li><p>supplying the wrong number or wrong types of parameters to a
prepared query, executing a prepared query with the wrong
connection, etc</p></li></ul></div><div class="SIntrapara">The following kinds of errors may cause a connection to be
disconnected:
</div><div class="SIntrapara"><ul><li><p>changing communication settings, such as changing the
connection’s character encoding</p></li><li><p>communication failures and internal errors in the library</p></li><li><p>a <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=breakhandler.html&version=6.1" class="Sq" data-pltdoc="x">break</a>
occurring during a connection operation</p></li></ul></div><div class="SIntrapara">See <a href="#%28part._transactions%29" data-pltdoc="x">Transactions</a> for information on how errors can affect
the transaction status.</div></p><p><span style="font-weight: bold">Character encoding</span><span class="hspace"> </span> This library is designed to interact with
database systems using the UTF-8 character encoding. The connection
functions attempt to negotiate UTF-8 communication at the beginning of
every connection, but some systems also allow the character encoding
to be changed via SQL commands (eg, <span class="stt">SET NAMES</span>). If this happens,
the client might be unable to reliably communicate with the database,
and data might get corrupted in transmission. Avoid changing a
connection’s character encoding. When possible, the connection will
observe the change and automatically disconnect with an error.</p><p><span style="font-weight: bold">Synchronization</span><span class="hspace"> </span> Connections are internally synchronized:
it is safe to use a connection from different threads
concurrently. Most connections are not kill-safe: killing a thread
that is using a connection may leave the connection locked, causing
future operations to block indefinitely. See also
<a href="connect.html#%28part._kill-safe%29" data-pltdoc="x">Kill-safe Connections</a>.</p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""query-statements"">3.1<tt> </tt><a name="(part._query-statements)"></a>Statements</h4><p><div class="SIntrapara">All query functions require both a connection and a
<a name="(tech._statement)"></a><span style="font-style: italic">statement</span>, which is one of the following:
</div><div class="SIntrapara"><ul><li><p>a string containing a single SQL statement</p></li><li><p>a <a href="#%28tech._prepared._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">prepared statement</span></a> produced by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="RktValLink" data-pltdoc="x">prepare</a></span></p></li><li><p>a <a href="#%28tech._virtual._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">virtual statement</span></a> produced by
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement%29%29" class="RktValLink" data-pltdoc="x">virtual-statement</a></span></p></li><li><p>a statement-binding value produced by
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="RktValLink" data-pltdoc="x">bind-prepared-statement</a></span></p></li><li><p>an instance of a struct type that implements <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prop~3astatement%29%29" class="RktValLink" data-pltdoc="x">prop:statement</a></span></p></li></ul></div></p><p>A SQL statement may contain parameter placeholders that stand for SQL
scalar values; such statements are called <a name="(tech._parameterized._query)"></a><span style="font-style: italic">parameterized
queries</span>. The parameter values must be supplied when the statement is
executed; the parameterized statement and parameter values are sent to
the database back end, which combines them correctly and safely.</p><p>Use parameters instead of Racket string operations (eg,
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._format%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">format</a></span> or <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string-append%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string-append</a></span>) to avoid
<a href="using-db.html#%28part._dbsec-sql-injection%29" data-pltdoc="x">SQL Injection</a>.</p><p>The syntax of placeholders varies depending on the database
system. For example:</p><blockquote class="SCentered"><table cellspacing="0" cellpadding="0"><tr><td><p>PostgreSQL: </p></td><td><p><span class="hspace"> </span></p></td><td><p> <span class="stt">select * from the_numbers where n > $1;</span> </p></td></tr><tr><td><p>
MySQL, ODBC: </p></td><td><p></p></td><td><p> <span class="stt">select * from the_numbers where n > ?;</span> </p></td></tr><tr><td><p>
SQLite: </p></td><td><p></p></td><td><p> supports both syntaxes (plus others)</p></td></tr></table></blockquote><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._statement~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">statement?</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">x</span> is a <a href="#%28tech._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">statement</span></a>, <span class="RktVal">#f</span>
otherwise.</div></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""Simple_Queries"">3.2<tt> </tt><a name="(part._.Simple_.Queries)"></a>Simple Queries</h4><p>The simple query API consists of a set of functions specialized to
various types of queries. For example, <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span> is
specialized to queries that return exactly one row of exactly one
column.</p><p>If a statement takes parameters, the parameter values are given as
additional arguments immediately after the SQL statement. Only a
statement given as a string, <a href="#%28tech._prepared._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">prepared statement</span></a>, or
<a href="#%28tech._virtual._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">virtual statement</span></a> can be given “inline” parameters; if the
statement is a statement-binding, no inline parameters are permitted.</p><p>The types of parameters and returned fields are described in
<a href="sql-types.html" data-pltdoc="x">SQL Types and Conversions</a>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-exec))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-exec%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-exec</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=void.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._void%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL statement for effect.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-exec%29%29" class="RktValLink" data-pltdoc="x">query-exec</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"insert into the_numbers values (42, 'the answer')"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-exec%29%29" class="RktValLink" data-pltdoc="x">query-exec</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"delete from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">42</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-rows))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-rows%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-rows</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">connection</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">stmt</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:group</span><span class="hspace"> </span><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:group-mode</span><span class="hspace"> </span><span class="RktVar">group-mode</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=vectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._vector%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vector?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">group-mode</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">preserve-null</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">list</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL query, which must produce rows, and returns the list
of rows (as vectors) from the query.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-rows%29%29" class="RktValLink" data-pltdoc="x">query-rows</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#(2 "company"))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-rows%29%29" class="RktValLink" data-pltdoc="x">query-rows</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktVal">"select 17"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#(17))</span></p></td></tr></table></blockquote></td></tr></table></p><p>If <span class="RktVar">groupings</span> is not empty, the result is the same as if
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="RktValLink" data-pltdoc="x">group-rows</a></span> had been called on the result rows.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-list))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-list</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL query, which must produce rows of exactly one
column, and returns the list of values from the query.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValLink" data-pltdoc="x">query-list</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktVal">"select n from the_numbers where n < 2"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(0 1)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValLink" data-pltdoc="x">query-list</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktVal">"select 'hello'"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'("hello")</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-row))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-row%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-row</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=vectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._vector%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vector?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL query, which must produce exactly one row, and
returns its (single) row result as a vector.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-row%29%29" class="RktValLink" data-pltdoc="x">query-row</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(2 "company")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-row%29%29" class="RktValLink" data-pltdoc="x">query-row</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select min(n), max(n) from the_numbers"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(0 3)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-maybe-row))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-row%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-maybe-row</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=vectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._vector%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-row%29%29" class="RktValLink" data-pltdoc="x">query-row</a></span>, but the query may produce zero rows; in
that case, <span class="RktVal">#f</span> is returned.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-row%29%29" class="RktValLink" data-pltdoc="x">query-maybe-row</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">100</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-row%29%29" class="RktValLink" data-pltdoc="x">query-maybe-row</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktVal">"select 17"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(17)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-value))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-value</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL query, which must produce exactly one row of exactly
one column, and returns its single value result.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select timestamp 'epoch'"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(sql-timestamp 1970 1 1 0 0 0 0 #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select d from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"a crowd"</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query-maybe-value))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-value%29%29" class="RktValDef RktValLink" data-pltdoc="x">query-maybe-value</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span>, but the query may produce zero rows; in
that case, <span class="RktVal">#f</span> is returned.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-value%29%29" class="RktValLink" data-pltdoc="x">query-maybe-value</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select d from the_numbers where n = $1"</span><span class="hspace"> </span><span class="RktVal">100</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-maybe-value%29%29" class="RktValLink" data-pltdoc="x">query-maybe-value</a></span><span class="hspace"> </span><span class="RktSym">c</span><span class="hspace"> </span><span class="RktVal">"select count(*) from the_numbers"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">4</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._in-query))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-query</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">connection</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">stmt</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:fetch</span><span class="hspace"> </span><span class="RktVar">fetch-size</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:group</span><span class="hspace"> </span><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:group-mode</span><span class="hspace"> </span><span class="RktVar">group-mode</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._sequence%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">sequence?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">fetch-size</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-positive-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-positive-integer?</a></span><span class="hspace"> </span><span class="RktVal">+inf.0</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">+inf.0</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">group-mode</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">preserve-null</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">list</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a SQL query, which must produce rows, and returns a
sequence. Each step in the sequence produces as many values as the
rows have columns.</div></p><p>If <span class="RktVar">fetch-size</span> is <span class="RktVal">+inf.0</span>, all rows are fetched when
the sequence is created. If <span class="RktVar">fetch-size</span> is finite, a
<a name="(tech._cursor)"></a><span style="font-style: italic">cursor</span> is created and <span class="RktVar">fetch-size</span> rows are fetched
at a time, allowing processing to be interleaved with retrieval. On
some database systems, ending a transaction implicitly closes all
open cursors; attempting to fetch more rows may fail. On PostgreSQL,
a cursor can be opened only within a transaction.</p><p>If <span class="RktVar">groupings</span> is not empty, the result is the same as
if <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="RktValLink" data-pltdoc="x">group-rows</a></span> had been called on the result rows. If
<span class="RktVar">groupings</span> is not empty, then <span class="RktVar">fetch-size</span> must
be <span class="RktVal">+inf.0</span>; otherwise, an exception is raised.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%252Flist%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for/list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="RktValLink" data-pltdoc="x">in-query</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select n from the_numbers where n < 2"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(0 1)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span><span class="hspace"> </span><span class="RktSym">pgc</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="RktValLink" data-pltdoc="x">in-query</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from the_numbers where n < $1"</span><span class="hspace"> </span><span class="RktVal">4</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:fetch</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._printf%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">printf</a></span><span class="hspace"> </span><span class="RktVal">"~a: ~a\n"</span><span class="hspace"> </span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktSym">d</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut">0: nothing</span></p></td></tr><tr><td><p><span class="RktOut">1: the loneliest number</span></p></td></tr><tr><td><p><span class="RktOut">2: company</span></p></td></tr><tr><td><p><span class="RktOut">3: a crowd</span></p></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr></table></blockquote></td></tr></table></p><p>An <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="RktValLink" data-pltdoc="x">in-query</a></span> application can provide better performance when
it appears directly in a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span> clause. In addition, it may
perform stricter checks on the number of columns returned by the query
based on the number of variables in the clause’s left-hand side:</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-query%29%29" class="RktValLink" data-pltdoc="x">in-query</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from the_numbers"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmisc..rkt%2529._displayln%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">displayln</a></span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktErr">in-query: query returned wrong number of columns</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">statement: "select * from the_numbers"</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">expected: 1</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">got: 2</span></p></td></tr></table></blockquote></td></tr></table></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""General_Query_Support"">3.3<tt> </tt><a name="(part._.General_.Query_.Support)"></a>General Query Support</h4><p>A general query result is either a <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._simple-result%29%29" class="RktValLink" data-pltdoc="x">simple-result</a></span> or a
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result%29%29" class="RktValLink" data-pltdoc="x">rows-result</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><p class="RForeground"><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="stt"> </span><a name="(def._((lib._db/base..rkt)._simple-result-info))"></a><a name="(def._((lib._db/base..rkt)._simple-result~3f))"></a><a name="(def._((lib._db/base..rkt)._struct~3asimple-result))"></a><a name="(def._((lib._db/base..rkt)._simple-result))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._simple-result%29%29" class="RktValDef RktValLink" data-pltdoc="x">simple-result</a></span></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">info</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">info</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._cons%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Represents the result of a SQL statement that does not return a
relation, such as an <span class="stt">INSERT</span> or <span class="stt">DELETE</span> statement.</div></p><p>The <span class="RktSym">info</span> field is an association list, but its contents vary
based on database system and may change in future versions of this
library (even new minor versions). The following keys are supported for
multiple database systems:</p><ul><li><p><span class="RktVal">'</span><span class="RktVal">insert-id</span>: If the value is a positive integer, the
statement was an <span class="stt">INSERT</span> statement and the value is a
system-specific identifier for the inserted row. For PostgreSQL, the
value is the row’s OID, if the table has OIDs (for an alternative, see
the <span class="stt">INSERT ... RETURNING</span> statement). For MySQL, the value is the
same as the result of
<a href="http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id">last_insert_id</a>
function—<wbr></wbr>that is, the value of the row’s <span class="stt">AUTO_INCREMENT</span>
field. If there is no such field, the value is <span class="RktVal">#f</span>. For
SQLite, the value is the same as the result of the
<a href="http://www.sqlite.org/lang_corefunc.html#last_insert_rowid">last_insert_rowid</a>
function—<wbr></wbr>that is, the
<a href="http://www.sqlite.org/lang_createtable.html#rowid">ROWID</a>
of the inserted row.</p></li><li><p><span class="RktVal">'</span><span class="RktVal">affected-rows</span>: The number (a nonnegative integer) of
rows inserted by an <span class="stt">INSERT</span> statement, modified by an <span class="stt">UPDATE</span>
statement, or deleted by a <span class="stt">DELETE</span> statement. Only directly
affected rows are counted; rows affected because of triggers or
integrity constraint actions are not counted.</p></li></ul><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><p class="RForeground"><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="stt"> </span><a name="(def._((lib._db/base..rkt)._rows-result-rows))"></a><a name="(def._((lib._db/base..rkt)._rows-result-headers))"></a><a name="(def._((lib._db/base..rkt)._rows-result~3f))"></a><a name="(def._((lib._db/base..rkt)._struct~3arows-result))"></a><a name="(def._((lib._db/base..rkt)._rows-result))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result%29%29" class="RktValDef RktValLink" data-pltdoc="x">rows-result</a></span></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym">headers</span><span class="stt"> </span><span class="RktSym">rows</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">headers</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">rows</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=vectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._vector%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vector?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Represents the result of SQL statement that results in a relation,
such as a <span class="stt">SELECT</span> query.</div></p><p>The <span class="RktSym">headers</span> field is a list whose length is the number of
columns in the result rows. Each header is usually an association list
containing information about the column, but do not rely on its
contents; it varies based on the database system and may change in
future version of this library (even new minor versions).</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._query))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query%29%29" class="RktValDef RktValLink" data-pltdoc="x">query</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._simple-result~3f%29%29" class="RktValLink" data-pltdoc="x">simple-result?</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result~3f%29%29" class="RktValLink" data-pltdoc="x">rows-result?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">arg</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Executes a query, returning a structure that describes the
results. Unlike the more specialized query functions, <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query%29%29" class="RktValLink" data-pltdoc="x">query</a></span>
supports both rows-returning and effect-only queries.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._group-rows))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="RktValDef RktValLink" data-pltdoc="x">group-rows</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">result</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:group</span><span class="hspace"> </span><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:group-mode</span><span class="hspace"> </span><span class="RktVar">group-mode</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result~3f%29%29" class="RktValLink" data-pltdoc="x">rows-result?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">result</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result~3f%29%29" class="RktValLink" data-pltdoc="x">rows-result?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">groupings</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym">grouping/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">group-mode</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">preserve-null</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">list</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></blockquote></div><div class="SIntrapara">If <span class="RktVar">groupings</span> is a vector, the elements must be names of
fields in <span class="RktVar">result</span>, and <span class="RktVar">result</span>’s rows are regrouped
using the given fields. Each grouped row contains N+1 fields; the
first N fields are the <span class="RktVar">groupings</span>, and the final field
is a list of “residual rows” over the rest of the fields. A residual
row of all NULLs is dropped (for convenient processing of <span class="stt">OUTER
JOIN</span> results) unless <span class="RktVar">group-mode</span> includes
<span class="RktVal">'</span><span class="RktVal">preserve-null</span>. If <span class="RktVar">group-mode</span> contains
<span class="RktVal">'</span><span class="RktVal">list</span>, there must be exactly one residual field, and its
values are included without a vector wrapper (similar to
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValLink" data-pltdoc="x">query-list</a></span>).</div></p><p>See also <a href="using-db.html#%28part._dbperf-n%2B1%29" data-pltdoc="x">The N+1 Selects Problem</a>.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">vehicles-result</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result%29%29" class="RktValLink" data-pltdoc="x">rows-result</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">name</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">"type"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">name</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">"maker"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">name</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">"model"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"car"</span><span class="hspace"> </span><span class="RktVal">"honda"</span><span class="hspace"> </span><span class="RktVal">"civic"</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"car"</span><span class="hspace"> </span><span class="RktVal">"ford"</span><span class="hspace"> </span><span class="RktVal">"focus"</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"car"</span><span class="hspace"> </span><span class="RktVal">"ford"</span><span class="hspace"> </span><span class="RktVal">"pinto"</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"bike"</span><span class="hspace"> </span><span class="RktVal">"giant"</span><span class="hspace"> </span><span class="RktVal">"boulder"</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"bike"</span><span class="hspace"> </span><span class="RktVal">"schwinn"</span><span class="hspace"> </span><span class="RktRdr">,</span><span class="RktSym"><a href="sql-types.html#%28def._%28%28lib._db%2Fbase..rkt%29._sql-null%29%29" class="RktValLink" data-pltdoc="x">sql-null</a></span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="RktValLink" data-pltdoc="x">group-rows</a></span><span class="hspace"> </span><span class="RktSym">vehicles-result</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:group</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"type"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">(rows-result</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">'(((name . "type"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">((name . "grouped") (grouped ((name . "maker")) ((name . "model")))))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">'(#("car" (#("honda" "civic") #("ford" "focus") #("ford" "pinto")))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">#("bike" (#("giant" "boulder") #("schwinn" #<sql-null>)))))</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></p><p>The grouped final column is given the name <span class="RktVal">"grouped"</span>.</p><p>The <span class="RktVar">groupings</span> argument may also be a list of vectors;
in that case, the grouping process is repeated for each set of
grouping fields. The grouping fields must be distinct.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._group-rows%29%29" class="RktValLink" data-pltdoc="x">group-rows</a></span><span class="hspace"> </span><span class="RktSym">vehicles-result</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:group</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"type"</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"maker"</span><span class="RktVal">)</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:group-mode</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">list</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">(rows-result</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">'(((name . "type"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">((name . "grouped")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(grouped</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">((name . "maker"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">((name . "grouped") (grouped ((name . "model")))))))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">'(#("car" (#("honda" ("civic")) #("ford" ("focus" "pinto"))))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">#("bike" (#("giant" ("boulder")) #("schwinn" ())))))</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._rows-~3edict))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-~3edict%29%29" class="RktValDef RktValLink" data-pltdoc="x">rows->dict</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">result</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:key</span><span class="hspace"> </span><span class="RktVar">key-field/s</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:value</span><span class="hspace"> </span><span class="RktVar">value-field/s</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:value-mode</span><span class="hspace"> </span><span class="RktVar">value-mode</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=dicts.html%23%2528def._%2528%2528lib._racket%252Fdict..rkt%2529._dict%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">dict?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">result</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-result~3f%29%29" class="RktValLink" data-pltdoc="x">rows-result?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">key-field/s</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">value-field/s</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fvector..rkt%2529._vectorof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">vectorof</a></span><span class="hspace"> </span><span class="RktSym">field/c</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">value-mode</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">list</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">preserve-null</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Creates a dictionary mapping <span class="RktVar">key-field/s</span> to
<span class="RktVar">value-field/s</span>. If <span class="RktVar">key-field/s</span> is a single field name
or index, the keys are the field values; if <span class="RktVar">key-field/s</span> is a
vector, the keys are vectors of the field values. Likewise for
<span class="RktVar">value-field/s</span>.</div></p><p>If <span class="RktVar">value-mode</span> contains <span class="RktVal">'</span><span class="RktVal">list</span>, a list of values is
accumulated for each key; otherwise, there must be at most one value
for each key. Values consisting of all <span class="RktSym"><a href="sql-types.html#%28def._%28%28lib._db%2Fbase..rkt%29._sql-null~3f%29%29" class="RktValLink" data-pltdoc="x">sql-null?</a></span> values are
dropped unless <span class="RktVar">value-mode</span> contains
<span class="RktVal">'</span><span class="RktVal">preserve-null</span>.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-~3edict%29%29" class="RktValLink" data-pltdoc="x">rows->dict</a></span><span class="hspace"> </span><span class="RktSym">vehicles-result</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:key</span><span class="hspace"> </span><span class="RktVal">"model"</span><span class="hspace"> </span><span class="RktPn">#:value</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">"type"</span><span class="hspace"> </span><span class="RktVal">"maker"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'#hash((#<sql-null> . #("bike" "schwinn"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("civic" . #("car" "honda"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("pinto" . #("car" "ford"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("focus" . #("car" "ford"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("boulder" . #("bike" "giant")))</span></p></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rows-~3edict%29%29" class="RktValLink" data-pltdoc="x">rows->dict</a></span><span class="hspace"> </span><span class="RktSym">vehicles-result</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:key</span><span class="hspace"> </span><span class="RktVal">"maker"</span><span class="hspace"> </span><span class="RktPn">#:value</span><span class="hspace"> </span><span class="RktVal">"model"</span><span class="hspace"> </span><span class="RktPn">#:value-mode</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">list</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'#hash(("ford" . ("focus" "pinto"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("honda" . ("civic"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("giant" . ("boulder"))</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">("schwinn" . ()))</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""Prepared_Statements"">3.4<tt> </tt><a name="(part._.Prepared_.Statements)"></a>Prepared Statements</h4><p>A <a name="(tech._prepared._statement)"></a><span style="font-style: italic">prepared statement</span> is the result of a call to
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="RktValLink" data-pltdoc="x">prepare</a></span>.</p><p>Any server-side or native-library resources associated with a prepared
statement are released when the prepared statement is
garbage-collected or when the connection that owns it is closed;
prepared statements do not need to be (and cannot be) explicitly
closed.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._prepare))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="RktValDef RktValLink" data-pltdoc="x">prepare</a></span></span><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span><span class="RktVar">stmt</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="RktValLink" data-pltdoc="x">prepared-statement?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">connection</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stmt</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement~3f%29%29" class="RktValLink" data-pltdoc="x">virtual-statement?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Prepares a statement. The resulting <a href="#%28tech._prepared._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">prepared statement</span></a> is
tied to the connection that prepared it; attempting to execute it
with another connection will trigger an exception. The prepared
statement holds its connection link weakly; a reference to a
prepared statement will not keep a connection from being garbage
collected.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._prepared-statement~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">prepared-statement?</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">x</span> is a <a href="#%28tech._prepared._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">prepared statement</span></a>
created by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="RktValLink" data-pltdoc="x">prepare</a></span>, <span class="RktVal">#f</span> otherwise.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._prepared-statement-parameter-types))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement-parameter-types%29%29" class="RktValDef RktValLink" data-pltdoc="x">prepared-statement-parameter-types</a></span></span><span class="hspace"> </span><span class="RktVar">pst</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._list%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">pst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="RktValLink" data-pltdoc="x">prepared-statement?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a list with one element for each of the prepared statement’s
parameters. Each element is itself a list of the following form:</div></p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVar">supported?</span><span class="hspace"> </span><span class="RktVar">type</span><span class="hspace"> </span><span class="RktVar">typeid</span><span class="RktPn">)</span></p></blockquote><p>The <span class="RktVar">supported?</span> field indicates whether the type is
supported by this library; the <span class="RktVar">type</span> field is a symbol
corresponding to an entry in one of the tables in
<a href="sql-types.html#%28part._db-types%29" data-pltdoc="x">SQL Type Conversions</a>; and the <span class="RktVar">typeid</span> field is a
system-specific type identifier. The type description list format
may be extended with additional information in future versions of
this library.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._prepared-statement-result-types))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement-result-types%29%29" class="RktValDef RktValLink" data-pltdoc="x">prepared-statement-result-types</a></span></span><span class="hspace"> </span><span class="RktVar">pst</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._list%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">pst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="RktValLink" data-pltdoc="x">prepared-statement?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">If <span class="RktVar">pst</span> is a rows-returning statement (eg, <span class="stt">SELECT</span>),
returns a list of type descriptions as described above, identifying
the SQL types (or pseudo-types) of the result columns. If
<span class="RktVar">pst</span> is not a rows-returning statement, the function returns
the empty list.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._bind-prepared-statement))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="RktValDef RktValLink" data-pltdoc="x">bind-prepared-statement</a></span></span><span class="hspace"> </span><span class="RktVar">pst</span><span class="hspace"> </span><span class="RktVar">params</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement-binding~3f%29%29" class="RktValLink" data-pltdoc="x">statement-binding?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">pst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepared-statement~3f%29%29" class="RktValLink" data-pltdoc="x">prepared-statement?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">params</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Creates a statement-binding value pairing <span class="RktVar">pst</span> with
<span class="RktVar">params</span>, a list of parameter arguments. The result can be
executed with <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query%29%29" class="RktValLink" data-pltdoc="x">query</a></span> or any of the other query functions,
but it must be used with the same connection that created
<span class="RktVar">pst</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%252A%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">let*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">get-name-pst</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prepare%29%29" class="RktValLink" data-pltdoc="x">prepare</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select d from the_numbers where n = $1"</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">get-name2</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="RktValLink" data-pltdoc="x">bind-prepared-statement</a></span><span class="hspace"> </span><span class="RktSym">get-name-pst</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">get-name3</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="RktValLink" data-pltdoc="x">bind-prepared-statement</a></span><span class="hspace"> </span><span class="RktSym">get-name-pst</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktSym">get-name2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-value%29%29" class="RktValLink" data-pltdoc="x">query-value</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktSym">get-name3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'("company" "a crowd")</span></p></td></tr></table></blockquote></td></tr></table></p><p>Most query functions perform the binding step implicitly.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._statement-binding~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement-binding~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">statement-binding?</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">x</span> is a statement created by
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._bind-prepared-statement%29%29" class="RktValLink" data-pltdoc="x">bind-prepared-statement</a></span>, <span class="RktVal">#f</span> otherwise.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._virtual-statement))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement%29%29" class="RktValDef RktValLink" data-pltdoc="x">virtual-statement</a></span></span><span class="hspace"> </span><span class="RktVar">gen</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement~3f%29%29" class="RktValLink" data-pltdoc="x">virtual-statement?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">gen</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._dbsystem~3f%29%29" class="RktValLink" data-pltdoc="x">dbsystem?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Creates a <a name="(tech._virtual._statement)"></a><span style="font-style: italic">virtual statement</span>, <span class="RktVar">stmt</span>, which
encapsulates a weak mapping of connections to prepared
statements. When a query function is called with <span class="RktVar">stmt</span> and
a connection, the weak hash is consulted to see if the statement has
already been prepared for that connection. If so, the prepared
statement is used; otherwise, the statement is prepared and stored
in the table.</div></p><p>The <span class="RktVar">gen</span> argument must be either a SQL string or a function
that accepts a databse system object and produces a SQL string. The
function variant allows the SQL syntax to be dynamically customized
for the database system in use.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">pst</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement%29%29" class="RktValLink" data-pltdoc="x">virtual-statement</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">dbsys</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=case.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fmore-scheme..rkt%2529._case%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">case</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._dbsystem-name%29%29" class="RktValLink" data-pltdoc="x">dbsystem-name</a></span><span class="hspace"> </span><span class="RktSym">dbsys</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">postgresql</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"select n from the_numbers where n < $1"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">sqlite3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"select n from the_numbers where n < ?"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._else%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">else</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=exns.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._error%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">error</a></span><span class="hspace"> </span><span class="RktVal">"unknown system"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValLink" data-pltdoc="x">query-list</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktSym">pst</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(0 1 2)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query-list%29%29" class="RktValLink" data-pltdoc="x">query-list</a></span><span class="hspace"> </span><span class="RktSym">slc</span><span class="hspace"> </span><span class="RktSym">pst</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(0 1 2)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._virtual-statement~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">virtual-statement?</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">x</span> is a <a href="#%28tech._virtual._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">virtual statement</span></a>
created by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._virtual-statement%29%29" class="RktValLink" data-pltdoc="x">virtual-statement</a></span>, <span class="RktVal">#f</span> otherwise.</div></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""transactions"">3.5<tt> </tt><a name="(part._transactions)"></a>Transactions</h4><p>The functions described in this section provide a consistent interface
to transactions.</p><p>A <a name="(tech._managed._transaction)"></a><span style="font-style: italic">managed transaction</span> is one created via either
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="RktValLink" data-pltdoc="x">start-transaction</a></span> or <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span>. In
contrast, an <a name="(tech._unmanaged._transaction)"></a><span style="font-style: italic">unmanaged transaction</span> is one created by
evaluating a SQL statement such as <span class="stt">START TRANSACTION</span>. A
<a name="(tech._nested._transaction)"></a><span style="font-style: italic">nested transaction</span> is a transaction created within the
extent of an existing transaction. If a nested transaction is
committed, its changes are promoted to the enclosing transaction,
which may itself be committed or rolled back. If a nested transaction
is rolled back, its changes are discarded, but the enclosing
transaction remains open. Nested transactions are implemented via SQL
<span class="stt">SAVEPOINT</span>, <span class="stt">RELEASE SAVEPOINT</span>, and <span class="stt">ROLLBACK TO
SAVEPOINT</span>.</p><p>ODBC connections must use <a href="#%28tech._managed._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">managed transactions</span></a> exclusively;
using transaction-changing SQL may cause these functions to behave
incorrectly and may cause additional problems in the ODBC driver. ODBC
connections do not support <a href="#%28tech._nested._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">nested transactions</span></a>.</p><p>PostgreSQL, MySQL, and SQLite connections must not mix <a href="#%28tech._managed._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">managed</span></a> and <a href="#%28tech._unmanaged._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">unmanaged</span></a> transactions. For example, calling
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="RktValLink" data-pltdoc="x">start-transaction</a></span> and then executing a <span class="stt">ROLLBACK</span>
statement is not allowed. Note that in MySQL, some SQL statements have
<a href="http://dev.mysql.com/doc/refman/5.0/en/implicit-commit.html">implicit
transaction effects</a>. For example, in MySQL a <span class="stt">CREATE TABLE</span>
statement implicitly commits the current transaction. These statements
also must not be used within <a href="#%28tech._managed._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">managed transactions</span></a>. (In
contrast, PostgreSQL and SQLite both support transactional DDL.)</p><p><div class="SIntrapara"><span style="font-weight: bold">Errors</span><span class="hspace"> </span> Query errors may affect an open transaction in one of
three ways:
</div><div class="SIntrapara"><ol><li><p>the transaction remains open and unchanged</p></li><li><p>the transaction is automatically rolled back</p></li><li><p>the transaction becomes an <a name="(tech._invalid._transaction)"></a><span style="font-style: italic">invalid transaction</span>; all
subsequent queries will fail until the transaction is rolled back</p></li></ol></div><div class="SIntrapara">To avoid the silent loss of information, this library attempts to
avoid behavior (2) completely by marking transactions as invalid
instead (3). Invalid transactions can be identified using the
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._needs-rollback~3f%29%29" class="RktValLink" data-pltdoc="x">needs-rollback?</a></span> function. The following list is a rough guide
to what errors cause which behaviors:
</div><div class="SIntrapara"><ul><li><p>All errors raised by checks performed by this library, such as
parameter arity and type errors, leave the transaction open and
unchanged (1).</p></li><li><p>All errors originating from PostgreSQL cause the transaction to
become <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> (3).</p></li><li><p>Most errors originating from MySQL leave the transaction open
and unchanged (1), but a few cause the transaction to become
<a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> (3). In the latter
cases, the underlying behavior of MySQL is to roll back the
transaction but <span style="font-style: italic">leave it open</span> (see
<a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-error-handling.html">the
MySQL documentation</a>). This library detects those cases and marks
the transaction <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a>
instead.</p></li><li><p>Most errors originating from SQLite leave the transaction open
and unchanged (1), but a few cause the transaction to become
<a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> (3). In the latter
cases, the underlying behavior of SQLite is to roll back the
transaction (see
<a href="http://www.sqlite.org/lang_transaction.html">the SQLite
documentation</a>). This library detects those cases and marks the
transaction <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> instead.</p></li><li><p>All errors originating from an ODBC driver cause the transaction
to become <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> (3). The
underlying behavior of ODBC drivers varies widely, and ODBC provides
no mechanism to detect when an existing transaction has been rolled
back, so this library intercepts all errors and marks the
transaction <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> instead.</p></li></ul></div><div class="SIntrapara">If a nested transaction marked <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a> is rolled back, the enclosing transaction is
typically still valid.</div></p><p>If a transaction is open when a connection is disconnected, it is
implicitly rolled back.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._start-transaction))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="RktValDef RktValLink" data-pltdoc="x">start-transaction</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">c</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:isolation</span><span class="hspace"> </span><span class="RktVar">isolation-level</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:option</span><span class="hspace"> </span><span class="RktVar">option</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=void.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._void%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">void?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">isolation-level</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">serializable</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">repeatable-read</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">read-committed</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">read-uncommitted</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktVal">#f</span></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">option</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Starts a transaction with isolation <span class="RktVar">isolation-level</span>. If
<span class="RktVar">isolation-level</span> is <span class="RktVal">#f</span>, the isolation is
database-dependent; it may be a default isolation level or it may be
the isolation level of the previous transaction.</div></p><p><div class="SIntrapara">The behavior of <span class="RktVar">option</span> depends on the database system:
</div><div class="SIntrapara"><ul><li><p>PostgreSQL supports <span class="RktVal">'</span><span class="RktVal">read-only</span> and <span class="RktVal">'</span><span class="RktVal">read-write</span>
for the <a href="http://www.postgresql.org/docs/9.0/static/sql-set-transaction.html">corresponding
transaction options</a>.</p></li><li><p>SQLite supports <span class="RktVal">'</span><span class="RktVal">deferred</span>, <span class="RktVal">'</span><span class="RktVal">immediate</span>, and
<span class="RktVal">'</span><span class="RktVal">exclusive</span> for the <a href="http://www.sqlite.org/lang_transaction.html">corresponding
locking modes</a>.</p></li><li><p>MySQL and ODBC no not support any options.</p></li></ul></div><div class="SIntrapara">If <span class="RktVar">option</span> is not supported, an exception is raised.</div></p><p>If <span class="RktVar">c</span> is already in a transaction, <span class="RktVar">isolation-level</span>
and <span class="RktVar">option</span> must both be <span class="RktVal">#f</span>, and a <a href="#%28tech._nested._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">nested
transaction</span></a> is opened.</p><p>See also <a href="using-db.html#%28part._dbperf-concurrency%29" data-pltdoc="x">Transactions and Concurrency</a>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._commit-transaction))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._commit-transaction%29%29" class="RktValDef RktValLink" data-pltdoc="x">commit-transaction</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=void.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._void%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Attempts to commit the current transaction, if one is open. If the
transaction cannot be commited (for example, if it is <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid</span></a>), an exception is raised.</div></p><p>If the current transaction is a <a href="#%28tech._nested._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">nested transaction</span></a>, the
nested transaction is closed, its changes are incorporated into the
enclosing transaction, and the enclosing transaction is resumed.</p><p>If no transaction is open, this function has no effect.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._rollback-transaction))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rollback-transaction%29%29" class="RktValDef RktValLink" data-pltdoc="x">rollback-transaction</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=void.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._void%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Rolls back the current transaction, if one is open.</div></p><p>If the current transaction is a <a href="#%28tech._nested._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">nested transaction</span></a>, the
nested transaction is closed, its changes are abandoned, and the
enclosing transaction is resumed.</p><p>If no transaction is open, this function has no effect.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._in-transaction~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._in-transaction~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">in-transaction?</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">c</span> has an open transaction
(<a href="#%28tech._managed._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">managed</span></a> or <a href="#%28tech._unmanaged._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">unmanaged</span></a>), <span class="RktVal">#f</span> otherwise.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._needs-rollback~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._needs-rollback~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">needs-rollback?</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">c</span> is in an <a href="#%28tech._invalid._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">invalid
transaction</span></a>. All queries executed using <span class="RktVar">c</span> will fail until
the transaction is rolled back (either using
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rollback-transaction%29%29" class="RktValLink" data-pltdoc="x">rollback-transaction</a></span>, if the transaction was created with
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="RktValLink" data-pltdoc="x">start-transaction</a></span>, or when the procedure passed to
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span> returns).</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._call-with-transaction))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValDef RktValLink" data-pltdoc="x">call-with-transaction</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">c</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">proc</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:isolation</span><span class="hspace"> </span><span class="RktVar">isolation-level</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:option</span><span class="hspace"> </span><span class="RktVar">option</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">any</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">proc</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">any</a></span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">isolation-level</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">serializable</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">repeatable-read</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">read-committed</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">read-uncommitted</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktVal">#f</span></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">option</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Calls <span class="RktVar">proc</span> in the context of a new transaction with
isolation level <span class="RktVar">isolation-level</span>. If <span class="RktVar">proc</span> completes
normally, the transaction is committed and <span class="RktVar">proc</span>’s results
are returned. If <span class="RktVar">proc</span> raises an exception (or if the
implicit commit at the end raises an exception), the transaction is
rolled back and the exception is re-raised.</div></p><p><div class="SIntrapara">If <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span> is called within a transaction,
<span class="RktVar">isolation-level</span> must be <span class="RktVal">#f</span>, and it creates a
<a href="#%28tech._nested._transaction%29" class="techoutside" data-pltdoc="x"><span class="techinside">nested transaction</span></a>. Within the extent of a call to
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span>, transactions must be properly
nested. In particular:
</div><div class="SIntrapara"><ul><li><p>Calling either <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._commit-transaction%29%29" class="RktValLink" data-pltdoc="x">commit-transaction</a></span> or
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._rollback-transaction%29%29" class="RktValLink" data-pltdoc="x">rollback-transaction</a></span> when the open transaction was
created by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span> causes an exception to be
raised.</p></li><li><p>If a further nested transaction is open when <span class="RktVar">proc</span>
completes (that is, created by an unmatched
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._start-transaction%29%29" class="RktValLink" data-pltdoc="x">start-transaction</a></span> call), an exception is raised and the
nested transaction created by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._call-with-transaction%29%29" class="RktValLink" data-pltdoc="x">call-with-transaction</a></span> is
rolled back.</p></li></ul></div></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""SQL_Errors"">3.6<tt> </tt><a name="(part._.S.Q.L_.Errors)"></a>SQL Errors</h4><p>SQL errors are represented by the <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql%29%29" class="RktValLink" data-pltdoc="x">exn:fail:sql</a></span> exception
type.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" cellpadding="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span></td><td><span class="hspace"> </span></td><td><a name="(def._((lib._db/base..rkt)._exn~3afail~3asql-info))"></a><a name="(def._((lib._db/base..rkt)._exn~3afail~3asql-sqlstate))"></a><a name="(def._((lib._db/base..rkt)._make-exn~3afail~3asql))"></a><a name="(def._((lib._db/base..rkt)._exn~3afail~3asql~3f))"></a><a name="(def._((lib._db/base..rkt)._struct~3aexn~3afail~3asql))"></a><a name="(def._((lib._db/base..rkt)._exn~3afail~3asql))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql%29%29" class="RktValDef RktValLink" data-pltdoc="x">exn:fail:sql</a></span></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=exns.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._exn%7E3afail%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exn:fail</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sqlstate</span><span class="stt"> </span><span class="RktSym">info</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">#:extra-constructor-name</span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._make-exn~3afail~3asql%29%29" class="RktValLink" data-pltdoc="x">make-exn:fail:sql</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">sqlstate</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktSym">info</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._cons%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Represents a SQL error originating from the database server or
native library. The <span class="RktSym">sqlstate</span> field contains the SQLSTATE
code (a five-character string) of the error for PostgreSQL, MySQL,
or ODBC connections or a symbol for SQLite connections. Refer to the
database system’s documentation for the definitions of error codes:</div></p><ul><li><p><a href="http://www.postgresql.org/docs/9.0/static/errcodes-appendix.html">PostgreSQL SQLSTATE codes</a></p></li><li><p><a href="http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html">MySQL SQLSTATE codes</a></p></li><li><p><a href="http://www.sqlite.org/c3ref/c_abort.html">SQLite error codes</a>; errors are represented as a symbol based on
the error constant’s name, such as <span class="RktVal">'</span><span class="RktVal">busy</span> for <span class="stt">SQLITE_BUSY</span></p></li><li><p>ODBC: see the database system’s documentation</p></li></ul><p>The <span class="RktSym">info</span> field contains all information available about the
error as an association list. The available keys vary, but the
<span class="RktVal">'</span><span class="RktVal">message</span> key is typically present; its value is a string
containing the error message.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=exns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fmore-scheme..rkt%2529._with-handlers%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">with-handlers</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql~3f%29%29" class="RktValLink" data-pltdoc="x">exn:fail:sql?</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql-info%29%29" class="RktValLink" data-pltdoc="x">exn:fail:sql-info</a></span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._query%29%29" class="RktValLink" data-pltdoc="x">query</a></span><span class="hspace"> </span><span class="RktSym">pgc</span><span class="hspace"> </span><span class="RktVal">"select * from nosuchtable"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'((severity . "ERROR")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(code . "42P01")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(message . "relation \"nosuchtable\" does not exist")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(position . "15")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(file . "parse_relation.c")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(line . "857")</span></p></td></tr><tr><td><p><span class="RktRes"></span><span class="hspace"> </span><span class="RktRes">(routine . "parserOpenTable"))</span></p></td></tr></table></td></tr></table></blockquote></td></tr></table></p><p>Errors originating from the <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">db</span></a> library, such as
arity and contract errors, type conversion errors, etc, are not
represented by <span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._exn~3afail~3asql%29%29" class="RktValLink" data-pltdoc="x">exn:fail:sql</a></span>.</p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""Database_Catalog_Information"">3.7<tt> </tt><a name="(part._.Database_.Catalog_.Information)"></a>Database Catalog Information</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._list-tables))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._list-tables%29%29" class="RktValDef RktValLink" data-pltdoc="x">list-tables</a></span></span><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>[<span class="RktPn">#:schema</span><span class="hspace"> </span><span class="RktVar">schema</span>]<span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._listof%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">schema</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">search-or-current</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">search</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">current</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktVal">'</span><span class="RktVal">search-or-current</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Returns a list of unqualified names of tables (and views) defined in
the current database.</div></p><p>If <span class="RktVar">schema</span> is <span class="RktVal">'</span><span class="RktVal">search</span>, the list contains all tables
in the current schema search path (with the possible exception of
system tables); if the search path cannot be determined, an exception
is raised. If <span class="RktVar">schema</span> is <span class="RktVal">'</span><span class="RktVal">current</span>, the list contains
all tables in the current schema. If <span class="RktVar">schema</span> is
<span class="RktVal">'</span><span class="RktVal">search-or-current</span> (the default), the search path is used if
it can be determined; otherwise the current schema is used.
The schema search path cannot be determined for ODBC-based
connections.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._db/base..rkt)._table-exists~3f))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._table-exists~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">table-exists?</a></span></span></td><td><span class="hspace"> </span></td><td><span class="RktVar">c</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">table-name</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:schema</span><span class="hspace"> </span><span class="RktVar">schema</span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktPn">#:case-sensitive?</span><span class="hspace"> </span><span class="RktVar">case-sensitive?</span>]<span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">table-name</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">schema</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">search-or-current</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">search</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">current</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td>=</td><td><span class="hspace"> </span></td><td><span class="RktVal">'</span><span class="RktVal">search-or-current</span></td></tr></table></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">case-sensitive?</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Indicates whether a table (or view) named <span class="RktVar">table-name</span>
exists. The meaning of the <span class="RktVar">schema</span> argument is the same as for
<span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._list-tables%29%29" class="RktValLink" data-pltdoc="x">list-tables</a></span>, and the <span class="RktVar">case-sensitive?</span> argument
controls how table names are compared.</div></p><h4 x-source-module="(lib "db/scribblings/db.scrbl")" x-part-tag=""Creating_New_Kinds_of_Statements"">3.8<tt> </tt><a name="(part._.Creating_.New_.Kinds_of_.Statements)"></a>Creating New Kinds of Statements</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>value</p></div></div><table cellspacing="0" cellpadding="0" class="argcontract RForeground"><tr><td><a name="(def._((lib._db/base..rkt)._prop~3astatement))"></a><span title="Provided from: db, db/base | Package: db-lib"><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._prop~3astatement%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:statement</a></span></span></td><td><span class="hspace"> </span>:<span class="hspace"> </span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Structure_Type_Property_Contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract..rkt%2529._struct-type-property%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">struct-type-property/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="connect.html#%28def._%28%28lib._db%2Fbase..rkt%29._connection~3f%29%29" class="RktValLink" data-pltdoc="x">connection?</a></span><span class="hspace"> </span><span class="RktSym"><a href="#%28def._%28%28lib._db%2Fbase..rkt%29._statement~3f%29%29" class="RktValLink" data-pltdoc="x">statement?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A struct type property for creating new kinds of statements. The
property value is applied to the struct instance and a connection, and
it must return a <a href="#%28tech._statement%29" class="techoutside" data-pltdoc="x"><span class="techinside">statement</span></a>.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="connect.html" title="backward to "2 Connections"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "DB: Database Connectivity"" data-pltdoc="x">up</a> <a href="sql-types.html" title="forward to "4 SQL Types and Conversions"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|