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

📄 group__lob.html

📁 Linux下的操作oracle数据库的连接库
💻 HTML
📖 第 1 页 / 共 5 页
字号:
{  <span class="keywordtype">char</span> * stmt =     <span class="stringliteral">"UPDATE T_SQLORA_BLOB SET CDATA = EMPTY_CLOB() WHERE KEY=:b1 "</span>    <span class="stringliteral">"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">"Update CLOB\n"</span>);  <span class="comment">/* fill the data buffer with some characters */</span>  fillbuf2(data, MAX_BLOB_BUFFER_DATA);  <span class="comment">/* parse the statement */</span>  <span class="keywordflow">if</span> (0&gt;(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 &gt; <a class="code" href="group__lob.html#ga205">sqlo_alloc_lob_desc</a>(dbh, &amp;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, &amp;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, &amp;loblp, 0, NULL, 0))      ) {    <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &amp;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, &amp;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 &lt; 0) {    <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &amp;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, &amp;loblp);  <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth);    <span class="keywordflow">return</span> (1);}<span class="keywordtype">void</span> fillbuf2(<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 &lt; 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#l07414">7414</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>.<p>Referenced by <a class="el" href="sqlora_8c-source.html#l07533">sqlo_lob_write_stream()</a>.    </td>  </tr></table><p>Here is the call graph for this function:<p><center><img src="group__lob_ga2_cgraph.png" border="0" usemap="#group__lob_ga2_cgraph_map" alt=""></center><map name="group__lob_ga2_cgraph_map"><area href="sqlora_8c.html#a128" shape="rect" coords="207,5,303,23" alt=""></map><a class="anchor" name="ga4" doxytag="sqlora.h::sqlo_lob_write_stream" ></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_write_stream </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#ga0">sqlo_db_handle_t</a>&nbsp;</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>&nbsp;</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&nbsp;</td>          <td class="mdname" nowrap> <em>filelen</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>FILE *&nbsp;</td>          <td class="mdname" nowrap> <em>fp</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Write lob data from a file into the lob column. <p>This function reads the data from the stream and writes it into the lob column via <a class="el" href="group__lob.html#ga2">sqlo_lob_write_buffer</a>.<p><dl compact><dt><b>Attention:</b></dt><dd>The function does not close or rewind the fp.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign=top><em>dbh</em>&nbsp;</td><td>I - A database handle. </td></tr>    <tr><td valign=top><em>loblp</em>&nbsp;</td><td>I - A lob locator. </td></tr>    <tr><td valign=top><em>filelen</em>&nbsp;</td><td>I - The size of the file (total lob length) </td></tr>    <tr><td valign=top><em>fp</em>&nbsp;</td><td>I - The filepointer</td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd><ul><li>SQLO_SUCCESS </li><li>SQLO_ERROR </li></ul></dd></dl><dl compact><dt><b>Since:</b></dt><dd>Version 2.2 </dd></dl><dl compact><dt><b>Example:</b></dt><dd><div class="fragment"><pre><span class="comment">/* $Id: ex14.c,v 1.4 2002/08/24 12:54:47 kpoitschke Exp $ */</span><span class="preprocessor">#include &lt;stdio.h&gt;</span><span class="preprocessor">#include &lt;stdlib.h&gt;</span><span class="preprocessor">#include "examples.h"</span><span class="keywordtype">int</span> insert_file_into_blob_table(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh, <span class="keywordtype">int</span> key, <span class="keyword">const</span> <span class="keywordtype">char</span> * fname ){  <span class="keywordtype">char</span> * stmt =     <span class="stringliteral">"INSERT INTO T_SQLORA_BLOB (KEY, BDATA) "</span>    <span class="stringliteral">"VALUES (:b1, EMPTY_BLOB()) RETURNING BDATA INTO :b2"</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;  FILE * fp;  <span class="keywordtype">unsigned</span> filelen;  <span class="keywordtype">short</span> ind;  <span class="keywordtype">int</span> k = key;  create_blob_table(dbh);  <span class="keywordflow">if</span> (! (fp = fopen(fname, <span class="stringliteral">"r"</span>))) {    printf(<span class="stringliteral">"ERROR: cannot open file %s\n"</span>, fname);    <span class="keywordflow">return</span> 0;  }  <span class="comment">/* determine file len */</span>  fseek(fp, 0, SEEK_END);  filelen = ftell(fp);  fseek(fp, 0, 0);  <span class="comment">/* parse */</span>  <span class="keywordflow">if</span> (0&gt;(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">/* allocate the lob locator */</span>  <span class="keywordflow">if</span> (0 &gt; <a class="code" href="group__lob.html#ga205">sqlo_alloc_lob_desc</a>(dbh, &amp;loblp))    error_exit(dbh, <span class="stringliteral">"sqlo_alloc_lob_desc"</span>);  <span class="comment">/* bind input variables */</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, &amp;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_BLOB, &amp;loblp, 0, &amp;ind, 0))      ) {    <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &amp;loblp);    error_exit(dbh, <span class="stringliteral">"sqlo_bind_by_pos"</span>);  }  <span class="comment">/* execute */</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, &amp;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#ga209">sqlo_lob_write_stream</a>(dbh, loblp, filelen, fp);  <span class="keywordflow">if</span> (status &lt; 0) {    <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &amp;loblp);    error_exit(dbh, <span class="stringliteral">"sqlo_lob_write_stream"</span>);  }  <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth);  <a class="code" href="group__lob.html#ga206">sqlo_free_lob_desc</a>(dbh, &amp;loblp);  fclose(fp);  <span class="keywordflow">return</span> (1);}<span class="comment">/* $Id */</span></pre></div></dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__lob.html#ga2">sqlo_lob_write_buffer</a> </dd></dl><p>Definition at line <a class="el" href="sqlora_8c-source.html#l07533">7533</a> of file <a class="el" href="sqlora_8c-source.html">sqlora.c</a>.<p>References <a class="el" href="sqlora_8c-source.html#l02905">_get_errcode()</a>, <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#a219a77">MAX_LONG_SIZE</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#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="sqlora_8c-source.html#l07414">sqlo_lob_write_buffer()</a>, <a class="el" href="group__constants.html#gga3a31">SQLO_NEED_DATA</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="group__constants.html#gga3a28">SQLO_STILL_EXECUTING</a>, <a class="el" href="group__constants.html#gga3a25">SQLO_SUCCESS</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_ga4_cgraph.png" border="0" usemap="#group__lob_ga4_cgraph_map" alt=""></center><map name="group__lob_ga4_cgraph_map"><area href="sqlora_8c.html#a118" shape="rect" coords="236,5,329,24" alt=""><area href="sqlora_8c.html#a128" shape="rect" coords="401,76,497,95" alt=""><area href="group__lob.html#ga2" shape="rect" coords="213,99,352,117" alt=""></map><hr size="1"><address style="align: right;"><small>Generated on Sun Jun 13 04:51:43 2004 for libsqlora8 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>

⌨️ 快捷键说明

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