📄 group__lob.html
字号:
{ <span class="keywordtype">char</span> * stmt = <span class="stringliteral">"INSERT INTO T_SQLORA_BLOB (KEY, CDATA) "</span> <span class="stringliteral">"VALUES (:b1, EMPTY_CLOB()) RETURNING CDATA INTO :b2"</span>; <span class="keywordtype">char</span> data[MAX_BLOB_BUFFER_DATA]; <span class="comment">/* a data buffer */</span> <a class="code" href="group__typedefs.html#ga2">sqlo_lob_desc_t</a> loblp; <span class="comment">/* the lob locator */</span> <a class="code" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth; <span class="keywordtype">int</span> status; <span class="keywordtype">int</span> k = key; printf(<span class="stringliteral">"Insert CLOB\n"</span>); <span class="comment">/* create the test table */</span> create_blob_table(dbh); <span class="comment">/* fill the data buffer with some characters */</span> fillbuf(data, MAX_BLOB_BUFFER_DATA); <span class="comment">/* parse the statement */</span> <span class="keywordflow">if</span> (0>(sth = <a class="code" href="group__complex.html#ga186">sqlo_prepare</a>(dbh, stmt))) error_exit(dbh, <span class="stringliteral">"sqlo_prepare"</span>); <span class="comment">/* alloate the lob descriptor */</span> <span class="keywordflow">if</span> (0 > <a class="code" href="group__lob.html#ga205">sqlo_alloc_lob_desc</a>(dbh, &loblp)) error_exit(dbh, <span class="stringliteral">"sqlo_alloc_lob_desc"</span>); <span class="comment">/* bind input variables. Note: we bind the lob descriptor here */</span> <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != (<a class="code" href="group__complex.html#ga190">sqlo_bind_by_pos</a>(sth, 1, SQLOT_INT, &k, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), NULL, 0)) || (<a class="code" href="group__complex.html#ga190">sqlo_bind_by_pos</a>(sth, 2, SQLOT_CLOB, &loblp, 0, NULL, 0)) ) { <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &loblp); error_exit(dbh, <span class="stringliteral">"sqlo_bind_by_pos"</span>); } <span class="comment">/* execute the statement */</span> status = <a class="code" href="group__complex.html#ga194">sqlo_execute</a>(sth, 1); <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != status) { <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &loblp); error_exit(dbh, <span class="stringliteral">"sqlo_execute"</span>); } <span class="comment">/* write the lob */</span> status = <a class="code" href="group__lob.html#ga207">sqlo_lob_write_buffer</a>(dbh, loblp, MAX_BLOB_BUFFER_DATA, data, MAX_BLOB_BUFFER_DATA, SQLO_ONE_PIECE); <span class="keywordflow">if</span> (status < 0) { <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &loblp); error_exit(dbh, <span class="stringliteral">"sqlo_log_write_buffer"</span>); } <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &loblp); <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth); <span class="keywordflow">return</span> (1);}<span class="keywordtype">void</span> create_blob_table(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh){ <span class="keywordtype">char</span> * stmt= <span class="stringliteral">"CREATE TABLE T_SQLORA_BLOB (KEY INTEGER, CDATA CLOB, BDATA BLOB)"</span>; <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__easy.html#ga163">sqlo_exec</a>(dbh, stmt)) <span class="keywordflow">if</span> (<a class="code" href="group__error.html#ga159">sqlo_geterrcode</a>(dbh) != 955) <span class="comment">/* table exists already */</span> error_exit(dbh, <span class="stringliteral">"sqlo_exec"</span>);}<span class="keywordtype">void</span> drop_blob_table(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh){ <span class="keywordtype">char</span> * stmt = <span class="stringliteral">"DROP TABLE T_SQLORA_BLOB"</span>; <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__easy.html#ga163">sqlo_exec</a>(dbh, stmt)) error_exit(dbh, <span class="stringliteral">"sqlo_exec"</span>);}<span class="keywordtype">void</span> fillbuf(<span class="keywordtype">char</span> * data, <span class="keywordtype">int</span> len){ <span class="keywordtype">int</span> i; <span class="keywordflow">for</span> (i = 0; i < len; ++i) { data[i] = <span class="charliteral">'A'</span> + i % 26; }}<span class="comment">/* $Id */</span></pre></div> </dd></dl><p>Definition at line <a class="el" href="sqlora_8c-source.html#l07469">7469</a> of file <a class="el" href="sqlora_8c-source.html">sqlora.c</a>.<p>References <a class="el" href="sqlora_8c-source.html#l04319">_get_trace_fp()</a>, <a class="el" href="sqlora_8c-source.html#l00340">CHECK_DBHANDLE</a>, <a class="el" href="sqlora_8c-source.html#l00416">CHECK_OCI_STATUS_RETURN</a>, <a class="el" href="sqlora_8c-source.html#l00483">_sqlo_db_struct::errhp</a>, <a class="el" href="sqlora_8c.html#a30">sqlo_db_struct_ptr_t</a>, <a class="el" href="group__constants.html#gga5a51">SQLO_FIRST_PIECE</a>, <a class="el" href="group__constants.html#gga4a34">SQLO_INVALID_DB_HANDLE</a>, <a class="el" href="group__constants.html#gga5a53">SQLO_LAST_PIECE</a>, <a class="el" href="group__constants.html#gga5a52">SQLO_NEXT_PIECE</a>, <a class="el" href="group__constants.html#gga5a50">SQLO_ONE_PIECE</a>, <a class="el" href="sqlora_8c-source.html#l00493">_sqlo_db_struct::status</a>, <a class="el" href="sqlora_8c-source.html#l00485">_sqlo_db_struct::svchp</a>, and <a class="el" href="sqlora_8c-source.html#l00238">TRACE</a>. </td> </tr></table><p>Here is the call graph for this function:<p><center><img src="group__lob_ga3_cgraph.png" border="0" usemap="#group__lob_ga3_cgraph_map" alt=""></center><map name="group__lob_ga3_cgraph_map"><area href="sqlora_8c.html#a128" shape="rect" coords="225,5,321,23" alt=""></map><a class="anchor" name="ga5" doxytag="sqlora.h::sqlo_lob_get_length" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int sqlo_lob_get_length </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> </td> <td class="mdname" nowrap> <em>dbh</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="group__typedefs.html#ga2">sqlo_lob_desc_t</a> </td> <td class="mdname" nowrap> <em>loblp</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned int * </td> <td class="mdname" nowrap> <em>loblenp</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the length of a lob. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>dbh</em> </td><td>I - Database handle </td></tr> <tr><td valign=top><em>loblp</em> </td><td>I - A lob descriptor </td></tr> <tr><td valign=top><em>loblenp</em> </td><td>O - The length of the lob</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd><ul><li>SQLO_SUCCESS </li><li>SQLO_STILL_EXECUTING </li><li>SQLO_ERROR </li></ul></dd></dl><p>Definition at line <a class="el" href="sqlora_8c-source.html#l07694">7694</a> of file <a class="el" href="sqlora_8c-source.html">sqlora.c</a>.<p>References <a class="el" href="sqlora_8c-source.html#l04319">_get_trace_fp()</a>, <a class="el" href="sqlora_8c-source.html#l00340">CHECK_DBHANDLE</a>, <a class="el" href="sqlora_8c-source.html#l00416">CHECK_OCI_STATUS_RETURN</a>, <a class="el" href="sqlora_8c-source.html#l00483">_sqlo_db_struct::errhp</a>, <a class="el" href="sqlora_8c-source.html#l00495">_sqlo_db_struct::errmsg</a>, <a class="el" href="sqlora_8c.html#a30">sqlo_db_struct_ptr_t</a>, <a class="el" href="group__constants.html#gga3a26">SQLO_ERROR</a>, <a class="el" href="group__constants.html#gga4a34">SQLO_INVALID_DB_HANDLE</a>, <a class="el" href="sqlora_8c-source.html#l00493">_sqlo_db_struct::status</a>, <a class="el" href="sqlora_8c-source.html#l00485">_sqlo_db_struct::svchp</a>, and <a class="el" href="sqlora_8c-source.html#l00238">TRACE</a>. </td> </tr></table><p>Here is the call graph for this function:<p><center><img src="group__lob_ga5_cgraph.png" border="0" usemap="#group__lob_ga5_cgraph_map" alt=""></center><map name="group__lob_ga5_cgraph_map"><area href="sqlora_8c.html#a128" shape="rect" coords="199,5,295,23" alt=""></map><a class="anchor" name="ga6" doxytag="sqlora.h::sqlo_lob_read_buffer" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int sqlo_lob_read_buffer </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> </td> <td class="mdname" nowrap> <em>dbh</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="group__typedefs.html#ga2">sqlo_lob_desc_t</a> </td> <td class="mdname" nowrap> <em>loblp</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned int </td> <td class="mdname" nowrap> <em>loblen</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>void * </td> <td class="mdname" nowrap> <em>bufp</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned int </td> <td class="mdname" nowrap> <em>bufl</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Read lob data from lob column into a buffer. <p>Reads data from the lob and writes it into the supplied buffer.<p>Use <a class="el" href="group__lob.html#ga5">sqlo_lob_get_length</a> to get the loblen you have to use here.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>dbh</em> </td><td>I - A database handle. </td></tr> <tr><td valign=top><em>loblp</em> </td><td>I - A lob locator. </td></tr> <tr><td valign=top><em>loblen</em> </td><td>I - The length of the lob </td></tr> <tr><td valign=top><em>bufp</em> </td><td>O - The output data. </td></tr> <tr><td valign=top><em>bufl</em> </td><td>I - The capacity of the buffer in terms of bytes.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd><ul><li>SQLO_SUCCESS </li><li>SQLO_NEED_DATA </li><li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -