📄 value_blob.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Obtaining SQL Function Parameter Values</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>Obtaining SQL Function Parameter Values</h2><blockquote><pre>const void *sqlite3_value_blob(sqlite3_value*);int sqlite3_value_bytes(sqlite3_value*);int sqlite3_value_bytes16(sqlite3_value*);double sqlite3_value_double(sqlite3_value*);int sqlite3_value_int(sqlite3_value*);sqlite3_int64 sqlite3_value_int64(sqlite3_value*);const unsigned char *sqlite3_value_text(sqlite3_value*);const void *sqlite3_value_text16(sqlite3_value*);const void *sqlite3_value_text16le(sqlite3_value*);const void *sqlite3_value_text16be(sqlite3_value*);int sqlite3_value_type(sqlite3_value*);int sqlite3_value_numeric_type(sqlite3_value*);</pre></blockquote><p>The C-language implementation of SQL functions and aggregates usesthis set of interface routines to access the parameter values onthe function or aggregate.</p><p>The xFunc (for scalar functions) or xStep (for aggregates) parametersto <a href="../c3ref/create_function.html">sqlite3_create_function()</a> and <a href="../c3ref/create_function.html">sqlite3_create_function16()</a>define callbacks that implement the SQL functions and aggregates.The 4th parameter to these callbacks is an array of pointers to<a href="../c3ref/value.html">protected sqlite3_value</a> objects. There is one <a href="../c3ref/value.html">sqlite3_value</a> object foreach parameter to the SQL function. These routines are used toextract values from the <a href="../c3ref/value.html">sqlite3_value</a> objects.</p><p>These routines work only with <a href="../c3ref/value.html">protected sqlite3_value</a> objects.Any attempt to use these routines on an <a href="../c3ref/value.html">unprotected sqlite3_value</a>object results in undefined behavior.</p><p>These routines work just like the corresponding<a href="../c3ref/column_blob.html">sqlite3_column_* routines</a> except thatthese routines take a single <a href="../c3ref/value.html">protected sqlite3_value</a> object pointerinstead of an <a href="../c3ref/stmt.html">sqlite3_stmt*</a> pointer and an integer column number.</p><p>The sqlite3_value_text16() interface extracts a UTF16 stringin the native byte-order of the host machine. Thesqlite3_value_text16be() and sqlite3_value_text16le() interfacesextract UTF16 strings as big-endian and little-endian respectively.</p><p>The sqlite3_value_numeric_type() interface attempts to applynumeric affinity to the value. This means that an attempt ismade to convert the value to an integer or floating point. Ifsuch a conversion is possible without loss of information (in otherwords if the value is a string that looks like a number)then the conversion is done. Otherwise no conversion occurs. The<a href="../c3ref/c_blob.html">datatype</a> after conversion is returned.</p><p>Please pay particular attention to the fact that the pointer thatis returned from <a href="../c3ref/value_blob.html">sqlite3_value_blob()</a>, <a href="../c3ref/value_blob.html">sqlite3_value_text()</a>, or<a href="../c3ref/value_blob.html">sqlite3_value_text16()</a> can be invalidated by a subsequent call to<a href="../c3ref/value_blob.html">sqlite3_value_bytes()</a>, <a href="../c3ref/value_blob.html">sqlite3_value_bytes16()</a>, <a href="../c3ref/value_blob.html">sqlite3_value_text()</a>,or <a href="../c3ref/value_blob.html">sqlite3_value_text16()</a>.</p><p>These routines must be called from the same thread asthe SQL function that supplied the <a href="../c3ref/value.html">sqlite3_value*</a> parameters.</p><p><h3>Invariants:</h3><table border="0" cellpadding="5" cellspacing="0"><tr><td valign="top">F15103</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_blob(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a blob and then returns apointer to the converted value.</td></tr><tr><td valign="top">F15106</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_bytes(V)</a> interface returns thenumber of bytes in the blob or string (exclusive of thezero terminator on the string) that was returned by themost recent call to <a href="../c3ref/value_blob.html">sqlite3_value_blob(V)</a> or<a href="../c3ref/value_blob.html">sqlite3_value_text(V)</a>.</td></tr><tr><td valign="top">F15109</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_bytes16(V)</a> interface returns thenumber of bytes in the string (exclusive of thezero terminator on the string) that was returned by themost recent call to <a href="../c3ref/value_blob.html">sqlite3_value_text16(V)</a>,<a href="../c3ref/value_blob.html">sqlite3_value_text16be(V)</a>, or <a href="../c3ref/value_blob.html">sqlite3_value_text16le(V)</a>.</td></tr><tr><td valign="top">F15112</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_double(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a floating point value andreturns a copy of that value.</td></tr><tr><td valign="top">F15115</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_int(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a 64-bit signed integer andreturns the lower 32 bits of that integer.</td></tr><tr><td valign="top">F15118</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_int64(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a 64-bit signed integer andreturns a copy of that integer.</td></tr><tr><td valign="top">F15121</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_text(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a zero-terminated UTF-8string and returns a pointer to that string.</td></tr><tr><td valign="top">F15124</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_text16(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a zero-terminated 2-bytealigned UTF-16 native byte orderstring and returns a pointer to that string.</td></tr><tr><td valign="top">F15127</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_text16be(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a zero-terminated 2-bytealigned UTF-16 big-endianstring and returns a pointer to that string.</td></tr><tr><td valign="top">F15130</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_text16le(V)</a> interface converts the<a href="../c3ref/value.html">protected sqlite3_value</a> object V into a zero-terminated 2-bytealigned UTF-16 little-endianstring and returns a pointer to that string.</td></tr><tr><td valign="top">F15133</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_type(V)</a> interface returnsone of <a href="../c3ref/c_blob.html">SQLITE_NULL</a>, <a href="../c3ref/c_blob.html">SQLITE_INTEGER</a>, <a href="../c3ref/c_blob.html">SQLITE_FLOAT</a>,<a href="../c3ref/c_blob.html">SQLITE_TEXT</a>, or <a href="../c3ref/c_blob.html">SQLITE_BLOB</a> as appropriate forthe <a href="../c3ref/value.html">sqlite3_value</a> object V.</td></tr><tr><td valign="top">F15136</td> <td valign="top">The <a href="../c3ref/value_blob.html">sqlite3_value_numeric_type(V)</a> interface convertsthe <a href="../c3ref/value.html">protected sqlite3_value</a> object V into either an integer ora floating point value if it can do so without loss ofinformation, and returns one of <a href="../c3ref/c_blob.html">SQLITE_NULL</a>,<a href="../c3ref/c_blob.html">SQLITE_INTEGER</a>, <a href="../c3ref/c_blob.html">SQLITE_FLOAT</a>, <a href="../c3ref/c_blob.html">SQLITE_TEXT</a>, or<a href="../c3ref/c_blob.html">SQLITE_BLOB</a> as appropriate forthe <a href="../c3ref/value.html">protected sqlite3_value</a> object V after the conversion attempt.</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 + -