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

📄 ex14_8c-example.html

📁 Linux下的操作oracle数据库的连接库
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>libsqlora8: Example Documentation</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <a class="qindex" href="examples.html">Examples</a></div><h1>ex14.c</h1>Example for loading a file into a blob column. <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 name="a20"></a><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 name="a21"></a><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 name="a22"></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 name="a23"></a><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 name="a24"></a><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 name="a25"></a><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 name="a26"></a><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> <hr size="1"><address style="align: right;"><small>Generated on Sun Jun 13 04:51:41 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 + -