⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bind_blob.html

📁 嵌入式数据库sqlite 3.5.9的文档
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Binding Values To Prepared Statements</title><style type="text/css">body {    margin: auto;    font-family: "Verdana" "sans-serif";    padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline {  float:right;  text-align:right;  font-style:italic;  width:240px;  margin:12px;  margin-top:58px;}.toolbar {  font-variant: small-caps;  text-align: center;  line-height: 1.6em;  margin: 0;  padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content    { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se  { background: url(../images/se.png) 100% 100% no-repeat #80a796}.sw  { background: url(../images/sw.png) 0% 100% no-repeat }.ne  { background: url(../images/ne.png) 100% 0% no-repeat }.nw  { background: url(../images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8">  </head><body><div><!-- container div to satisfy validator --><a href="../index.html"><img class="logo" src="../images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td>  <div class="se"><div class="sw"><div class="ne"><div class="nw">  <div class="toolbar">    <a href="../about.html">About</a>    <a href="../sitemap.html">Sitemap</a>    <a href="../docs.html">Documentation</a>    <a href="../download.html">Download</a>    <a href="../copyright.html">License</a>    <a href="../news.html">News</a>    <a href="http://www.sqlite.org/cvstrac/index">Developers</a>    <a href="../support.html">Support</a>  </div></div></div></div></div></td></tr></table>  <a href="intro.html"><h2>SQLite C Interface</h2></a><h2>Binding Values To Prepared Statements</h2><blockquote><pre>int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));int sqlite3_bind_double(sqlite3_stmt*, int, double);int sqlite3_bind_int(sqlite3_stmt*, int, int);int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);int sqlite3_bind_null(sqlite3_stmt*, int);int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);</pre></blockquote><p>In the SQL strings input to <a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> and itsvariants, literals may be replace by a parameter in oneof these forms:</p><p><ul><li>  ?<li>  ?NNN<li>  :VVV<li>  @VVV<li>  $VVV</ul></p><p>In the parameter forms shown above NNN is an integer literal,VVV alpha-numeric parameter name.The values of these parameters (also called "host parameter names"or "SQL parameters")can be set using the sqlite3_bind_*() routines defined here.</p><p>The first argument to the sqlite3_bind_*() routines alwaysis a pointer to the <a href="../c3ref/stmt.html">sqlite3_stmt</a> object returned from<a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> or its variants. The secondargument is the index of the parameter to be set. Thefirst parameter has an index of 1.  When the same namedparameter is used more than once, second and subsequentoccurrences have the same index as the first occurrence.The index for named parameters can be looked up using the<a href="../c3ref/bind_parameter_name.html">sqlite3_bind_parameter_name()</a> API if desired.  The indexfor "?NNN" parameters is the value of NNN.The NNN value must be between 1 and the compile-timeparameter SQLITE_MAX_VARIABLE_NUMBER (default value: 999).</p><p>The third argument is the value to bind to the parameter.</p><p>In thoseroutines that have a fourth argument, its value is the number of bytesin the parameter.  To be clear: the value is the number of <u>bytes</u>in the value, not the number of characters.If the fourth parameter is negative, the length of the string isnumber of bytes up to the first zero terminator.</p><p>The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), andsqlite3_bind_text16() is a destructor used to dispose of the BLOB orstring after SQLite has finished with it. If the fifth argument isthe special value <a href="../c3ref/c_static.html">SQLITE_STATIC</a>, then SQLite assumes that theinformation is in static, unmanaged space and does not need to be freed.If the fifth argument has the value <a href="../c3ref/c_static.html">SQLITE_TRANSIENT</a>, thenSQLite makes its own private copy of the data immediately, beforethe sqlite3_bind_*() routine returns.</p><p>The sqlite3_bind_zeroblob() routine binds a BLOB of length N thatis filled with zeros.  A zeroblob uses a fixed amount of memory(just an integer to hold it size) while it is being processed.Zeroblobs are intended to serve as place-holders for BLOBs whosecontent is later written using<a href="../c3ref/blob_open.html">increment BLOB I/O</a> routines. A negativevalue for the zeroblob results in a zero-length BLOB.</p><p>The sqlite3_bind_*() routines must be called after<a href="../c3ref/prepare.html">sqlite3_prepare_v2()</a> (and its variants) or <a href="../c3ref/reset.html">sqlite3_reset()</a> andbefore <a href="../c3ref/step.html">sqlite3_step()</a>.Bindings are not cleared by the <a href="../c3ref/reset.html">sqlite3_reset()</a> routine.Unbound parameters are interpreted as NULL.</p><p>These routines return <a href="../c3ref/c_abort.html">SQLITE_OK</a> on success or an error code ifanything goes wrong.  <a href="../c3ref/c_abort.html">SQLITE_RANGE</a> is returned if the parameterindex is out of range.  <a href="../c3ref/c_abort.html">SQLITE_NOMEM</a> is returned if malloc fails.<a href="../c3ref/c_abort.html">SQLITE_MISUSE</a> might be returned if these routines are called on avirtual machine that is the wrong state or which has already been finalized.Detection of misuse is unreliable.  Applications should not dependon SQLITE_MISUSE returns.  SQLITE_MISUSE is intended to indicate aa logic error in the application.  Future versions of SQLite mightpanic rather than return SQLITE_MISUSE.</p><p>See also: <a href="../c3ref/bind_parameter_count.html">sqlite3_bind_parameter_count()</a>,<a href="../c3ref/bind_parameter_name.html">sqlite3_bind_parameter_name()</a>, and<a href="../c3ref/bind_parameter_index.html">sqlite3_bind_parameter_index()</a>.</p><p><h3>Invariants:</h3><table border="0" cellpadding="5" cellspacing="0"><tr><td valign="top">F13506</td> <td valign="top">The <a href="../c3ref/prepare.html">SQL statement compiler</a> recognizestokens of the forms "?", "?NNN", "$VVV", ":VVV", and "@VVV"as SQL parameters, where NNN is any sequence of one or moredigits and where VVV is any sequence of one or morealphanumeric characters or "::" optionally followed bya string containing no spaces and contained within parentheses.</td></tr><tr><td valign="top">F13509</td> <td valign="top">The initial value of an SQL parameter is NULL.</td></tr><tr><td valign="top">F13512</td> <td valign="top">The index of an "?" SQL parameter is one larger than thelargest index of SQL parameter to the left, or 1 ifthe "?" is the leftmost SQL parameter.</td></tr><tr><td valign="top">F13515</td> <td valign="top">The index of an "?NNN" SQL parameter is the integer NNN.</td></tr><tr><td valign="top">F13518</td> <td valign="top">The index of an ":VVV", "$VVV", or "@VVV" SQL parameter isthe same as the index of leftmost occurances of the sameparameter, or one more than the largest index over allparameters to the left if this is the first occurranceof this parameter, or 1 if this is the leftmost parameter.</td></tr><tr><td valign="top">F13521</td> <td valign="top">The <a href="../c3ref/prepare.html">SQL statement compiler</a> fail withan <a href="../c3ref/c_abort.html">SQLITE_RANGE</a> error if the index of an SQL parameteris less than 1 or greater than SQLITE_MAX_VARIABLE_NUMBER.</td></tr><tr><td valign="top">F13524</td> <td valign="top">Calls to <a href="../c3ref/bind_blob.html">sqlite3_bind(S,N,V,...)</a>associate the value V with all SQL parameters having anindex of N in the <a href="../c3ref/stmt.html">prepared statement</a> S.</td></tr><tr><td valign="top">F13527</td> <td valign="top">Calls to <a href="../c3ref/bind_blob.html">sqlite3_bind(S,N,...)</a>override prior calls with the same values of S and N.</td></tr><tr><td valign="top">F13530</td> <td valign="top">Bindings established by <a href="../c3ref/bind_blob.html">sqlite3_bind(S,...)</a>persist across calls to <a href="../c3ref/reset.html">sqlite3_reset(S)</a>.</td></tr><tr><td valign="top">F13533</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_blob(S,N,V,L,D)</a>,<a href="../c3ref/bind_blob.html">sqlite3_bind_text(S,N,V,L,D)</a>, or<a href="../c3ref/bind_blob.html">sqlite3_bind_text16(S,N,V,L,D)</a> SQLite binds the first Lbytes of the blob or string pointed to by V, when Lis non-negative.</td></tr><tr><td valign="top">F13536</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_text(S,N,V,L,D)</a> or<a href="../c3ref/bind_blob.html">sqlite3_bind_text16(S,N,V,L,D)</a> SQLite binds charactersfrom V through the first zero character when L is negative.</td></tr><tr><td valign="top">F13539</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_blob(S,N,V,L,D)</a>,<a href="../c3ref/bind_blob.html">sqlite3_bind_text(S,N,V,L,D)</a>, or<a href="../c3ref/bind_blob.html">sqlite3_bind_text16(S,N,V,L,D)</a> when D is the specialconstant <a href="../c3ref/c_static.html">SQLITE_STATIC</a>, SQLite assumes that the value Vis held in static unmanaged space that will not changeduring the lifetime of the binding.</td></tr><tr><td valign="top">F13542</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_blob(S,N,V,L,D)</a>,<a href="../c3ref/bind_blob.html">sqlite3_bind_text(S,N,V,L,D)</a>, or<a href="../c3ref/bind_blob.html">sqlite3_bind_text16(S,N,V,L,D)</a> when D is the specialconstant <a href="../c3ref/c_static.html">SQLITE_TRANSIENT</a>, the routine makes aprivate copy of V value before it returns.</td></tr><tr><td valign="top">F13545</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_blob(S,N,V,L,D)</a>,<a href="../c3ref/bind_blob.html">sqlite3_bind_text(S,N,V,L,D)</a>, or<a href="../c3ref/bind_blob.html">sqlite3_bind_text16(S,N,V,L,D)</a> when D is a pointer toa function, SQLite invokes that function to destroy theV value after it has finished using the V value.</td></tr><tr><td valign="top">F13548</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_zeroblob(S,N,V,L)</a> the value boundis a blob of L bytes, or a zero-length blob if L is negative.</td></tr><tr><td valign="top">F13551</td> <td valign="top">In calls to <a href="../c3ref/bind_blob.html">sqlite3_bind_value(S,N,V)</a> the V argument maybe either a <a href="../c3ref/value.html">protected sqlite3_value</a> object or an<a href="../c3ref/value.html">unprotected sqlite3_value</a> object.</td></tr></table></p><p>See also lists of  <a href="objlist.html">Objects</a>,  <a href="constlist.html">Constants</a>, and  <a href="funclist.html">Functions</a>.</p><hr><small><i>This page last modified 2008/05/12 13:08:44 UTC</i></small></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -