group__lob.html

来自「一个很好用的Linux/Unix下Oracle OCI开发接口封装库」· HTML 代码 · 共 1,040 行 · 第 1/4 页

HTML
1,040
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Functions to insert/select LOBs</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindex" href="examples.html">Examples</a> &nbsp; </center>
<hr><h1>Functions to insert/select LOBs</h1><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a0">sqlo_alloc_lob_desc</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> *loblpp)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Allocate a lob descriptor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a1">sqlo_free_lob_desc</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> *loblpp)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Free a lob descriptor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a2">sqlo_lob_write_buffer</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int loblen, void *bufp, unsigned int bufl, unsigned int piece)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Write lob data from buffer into the lob column.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a3">sqlo_lob_append_buffer</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int loblen, void *bufp, unsigned int bufl, unsigned int piece)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Append lob data from buffer to the lob column.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a4">sqlo_lob_write_stream</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int filelen, FILE *fp)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Write lob data from a file into the lob column.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a5">sqlo_lob_get_length</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int *loblenp)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Get the length of a lob.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a6">sqlo_lob_read_buffer</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int loblen, void *bufp, unsigned int bufl)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Read lob data from lob column into a buffer.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="group__lob.html#a7">sqlo_lob_read_stream</a> (<a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> loblp, unsigned int loblen, FILE *fp)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>Read lob data from lob column into a stream.</em> <a href="#a7"></a><em></em></font><br><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a name="a0" doxytag="sqlora.h::sqlo_alloc_lob_desc"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int sqlo_alloc_lob_desc </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a>&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>dbh</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> *&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>loblpp</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>
Allocate a lob descriptor.
<p>
<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>loblpp</em>&nbsp;</td><td>
O - The lob locator</td></tr>
</table>
</dl><dl compact><dt><b>Returns: </b></dt><dd>
SQLO_SUCCESS or &lt; 0 on error </dl><dl compact><dt><b>Since: </b></dt><dd>
Version 2.2 </dl><dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="ex13_8c-example.html#a1">ex13.c</a>, <a class="el" href="ex14_8c-example.html#a1">ex14.c</a>, <a class="el" href="ex15_8c-example.html#a2">ex15.c</a>, and <a class="el" href="ex16_8c-example.html#a2">ex16.c</a>.</dl>    </td>
  </tr>
</table>
<a name="a1" doxytag="sqlora.h::sqlo_free_lob_desc"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int sqlo_free_lob_desc </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a>&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>dbh</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a> *&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>loblpp</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>
Free a lob descriptor.
<p>
Frees the descriptor and sets *loblp to NULL.<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>loblpp</em>&nbsp;</td><td>
I/O - A address where we find the lob locator.</td></tr>
</table>
</dl><dl compact><dt><b>Returns: </b></dt><dd>
<ul>
<li>SQLO_SUCCESS <li> &lt; 0 on error </ul>
</dl><dl compact><dt><b>Since: </b></dt><dd>
Version 2.2 </dl><dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="ex13_8c-example.html#a3">ex13.c</a>, <a class="el" href="ex14_8c-example.html#a3">ex14.c</a>, <a class="el" href="ex15_8c-example.html#a4">ex15.c</a>, and <a class="el" href="ex16_8c-example.html#a4">ex16.c</a>.</dl>    </td>
  </tr>
</table>
<a name="a3" doxytag="sqlora.h::sqlo_lob_append_buffer"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> int sqlo_lob_append_buffer </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#a0">sqlo_db_handle_t</a>&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>dbh</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="group__typedefs.html#a2">sqlo_lob_desc_t</a>&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>loblp</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned int&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>loblen</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>void *&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>bufp</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned int&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>bufl</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md" nowrap>unsigned int&nbsp;</td>
          <td class="mdname" nowrap>&nbsp; <em>piece</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>
Append lob data from buffer to the lob column.
<p>
<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>loblen</em>&nbsp;</td><td>
I - The length of the lob. </td></tr>
<tr><td valign=top><em>loblp</em>&nbsp;</td><td>
I - A lob locator. </td></tr>
<tr><td valign=top><em>bufp</em>&nbsp;</td><td>
I - A buffer of data. </td></tr>
<tr><td valign=top><em>bufl</em>&nbsp;</td><td>
I - The length of the buffer in terms of bytes. </td></tr>
<tr><td valign=top><em>piece</em>&nbsp;</td><td>
I - The piece indicator <ul>
<li>SQLO_ONE_PIECE <li>SQLO_FIRST_PIECE <li>SQLO_NEXT_PIECE <li>SQLO_LAST_PIECE </ul>
</td></tr>
</table>
</dl><dl compact><dt><b>Returns: </b></dt><dd>
<ul>
<li>SQLO_SUCCESS <li>SQLO_STILL_EXECUTING <li>SQLO_ERROR (always when OCILobWriteAppend is not available in your Oracle version) </ul>
</dl><dl compact><dt><b>Since: </b></dt><dd>
Version 2.2 and Oracle version &gt;= 8.1 </dl><dl compact><dt><b>Example:</b></dt><dd>
 <div class="fragment"><pre><span class="comment">/* $Id: group__lob.html,v 1.1 2005/01/13 02:56:43 cvsroot 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_into_blob_table(<a class="code" href="group__typedefs.html#a0">sqlo_db_handle_t</a> dbh, <span class="keywordtype">int</span> key )
{
  <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#a2">sqlo_lob_desc_t</a> loblp;                  <span class="comment">/* the lob locator */</span>
  <a class="code" href="group__typedefs.html#a1">sqlo_stmt_handle_t</a> sth;
  <span class="keywordtype">int</span> status;
  <span class="keywordtype">int</span> k = key;


  <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&gt;(sth = <a class="code" href="group__complex.html#a0">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#a0">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#a3a25">SQLO_SUCCESS</a> != 
      (<a class="code" href="group__complex.html#a3">sqlo_bind_by_pos</a>(sth, 1, <a class="code" href="group__constants.html#a6a56">SQLOT_INT</a>, &amp;k, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), NULL, 0)) ||
      (<a class="code" href="group__complex.html#a3">sqlo_bind_by_pos</a>(sth, 2, <a class="code" href="group__constants.html#a6a81">SQLOT_CLOB</a>, &amp;loblp, 0, NULL, 0))
      ) {
    <a class="code" href="group__lob.html#a1">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#a8">sqlo_execute</a>(sth, 1);

⌨️ 快捷键说明

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