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

📄 group__g__long.html

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>OCILIB (C Driver for Oracle): Long objects</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.4 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="modules.html"><span>Modules</span></a></li>    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>    <li><a href="files.html"><span>Files</span></a></li>  </ul></div><h1>Long objects</h1><hr><a name="_details"></a><h2>Detailed Description</h2>Long Objects encapsulate Oracle LONGs datatypes and were used to store large buffers in Oracle database.<p>They're still supported but are depreciated. Oracle now provides a newer and better way to deal with data that needs large storage : LOBs<p>OCILIB supports this datatype because it was and still is widely used<p>OCILIB provides a set of API for manipulating LONGs that is really close to the one provided for LOBs.<p>OCIB currently supports 3 types of Long Objects:<p><ul><li>OCI_BLONG : LONG RAW columns</li><li>OCI_CLONG : LONG columns</li></ul><p><a class="el" href="struct_o_c_i___lob.html" title="Oracle Internal Large objects:.">OCI_Lob</a> objects can be :<p><ul><li>Created as standalone instances</li><li>Used for in/out binding</li><li>Retrieved from select statement</li></ul><p><dl class="user" compact><dt><b>Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="preprocessor">#include "ocilib.h"</span><span class="preprocessor">#define FILENAME "data.lst"</span><span class="preprocessor"></span><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>){    <a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *cn;    <a class="code" href="struct_o_c_i___statement.html" title="Oracle SQL or PL/SQL statement.">OCI_Statement</a> *st;    <a class="code" href="struct_o_c_i___long.html" title="Oracle Long datatype.">OCI_Long</a> *lg;    FILE *f;    <span class="keywordtype">char</span> buffer[2048];    <span class="keywordtype">int</span> n;    <span class="keywordflow">if</span> (!<a class="code" href="group__g__init.html#gcdb642d75f7c8478e083634144bc813c" title="Initializes the library.">OCI_Initialize</a>(NULL, NULL, OCI_ENV_DEFAULT))        <span class="keywordflow">return</span> EXIT_FAILURE;    cn = <a class="code" href="group__g__connect.html#gdb6e2cdf759587dd81c2fda7c5f44338" title="Create a physical connection to an Oracle database server.">OCI_ConnectionCreate</a>(<span class="stringliteral">"db"</span>, <span class="stringliteral">"usr"</span>, <span class="stringliteral">"pwd"</span>, OCI_SESSION_DEFAULT);    st = <a class="code" href="group__g__exec.html#g335822f983af0fb5c529431f06a9a17b" title="Create a statement object and return its handle.">OCI_StatementCreate</a>(cn);      <span class="comment">/* open the app file */</span>    f = fopen(FILENAME, <span class="stringliteral">"rb"</span>);    <span class="keywordflow">if</span> (f)    {        fseek (f , 0 , SEEK_END);         n = ftell(f);         rewind (f);            printf(<span class="stringliteral">"\n%d bytes to write\n"</span>, n);        lg = <a class="code" href="group__g__long.html#g040ec19ae09a29b34e0143e39ab30939" title="Create a local temporary Long instance.">OCI_LongCreate</a>(st, OCI_BLONG);        <a class="code" href="group__g__exec.html#gd5a7fcffe7d24da001e44636cfc06578" title="Prepare a SQL statement or PL/SQL block.">OCI_Prepare</a>(st,  <span class="stringliteral">"insert into test_long_raw(code, content) values (1, :data)"</span>);        <a class="code" href="group__g__bind.html#gec1215548d35bff084c1284e303f31f6" title="Bind a Long variable.">OCI_BindLong</a>(st, <span class="stringliteral">":data"</span>, lg, n);        <a class="code" href="group__g__exec.html#g7189aa353845909aaedc8d5956429450" title="Execute a prepared SQL statement or PL/SQL block.">OCI_Execute</a>(st);        <span class="comment">/* write data into table by chunks of 2048 bytes */</span>               <span class="keywordflow">while</span> ((n = fread(buffer, 1, <span class="keyword">sizeof</span>(buffer), f)))        {            <a class="code" href="group__g__long.html#g1a76c2c5de1c81d38be17bf28524ce99" title="Write a buffer into a Long.">OCI_LongWrite</a>(lg, buffer, n);        }        printf(<span class="stringliteral">"\n%d bytes written\n"</span>, <a class="code" href="group__g__long.html#gf7ed15bc901e38b9bc3394f334bf8d4c" title="Return the buffer size of a long object in bytes (OCI_BLONG) or character (OCI_CLONG)...">OCI_LongGetSize</a>(lg));        fclose(f);        <a class="code" href="group__g__long.html#gdc23551bd5aa7832cbaee4e32a2b283a" title="Free a local temporary long.">OCI_LongFree</a>(lg);        <a class="code" href="group__g__transac.html#gee1ba614ed2dc5bd83bf788ca08f3e71" title="Commit current pending changes.">OCI_Commit</a>(cn);    }    <span class="comment">/* FETCHING LONGS  -------------------------------------------- */</span>     <a class="code" href="group__g__exec.html#gf2163ec44e644cc734c393188707985b" title="Parse and execute a SQL statement or PL/SQL block.">OCI_ExecuteStmt</a>(st, <span class="stringliteral">"select content from test_long_raw where code = 1"</span>);    <a class="code" href="group__g__stmt.html#g0aec6183761a7d90307ba785733888e0" title="Set the LONG datatype piece buffer size.">OCI_SetLongMaxSize</a>(st, 1000000);    rs = <a class="code" href="group__g__fetch.html#gf2a9e28b66a9538ba0ffb62bffb87c16" title="Retrieve the resultset handle from an executed statement.">OCI_GetResultset</a>(st);    <span class="comment">/* read data by chunks of 2048 bytes*/</span>           <span class="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs))    {        lg = <a class="code" href="group__g__fetch.html#g8c750dc1ea6d90c61cc2ebff5fb0c561" title="Return the current Long value of the column at the given index in the resultset.">OCI_GetLong</a>(rs, 1);        <span class="keywordflow">while</span> ((n = <a class="code" href="group__g__long.html#gd7e0ba53269cc2d5aace557a984c8717" title="Read a portion of a long into the given buffer [Obsolete].">OCI_LongRead</a>(lg, buffer, <span class="keyword">sizeof</span>(buffer)))) {}        printf(<span class="stringliteral">"\n%d bytes read\n"</span>, <a class="code" href="group__g__long.html#gf7ed15bc901e38b9bc3394f334bf8d4c" title="Return the buffer size of a long object in bytes (OCI_BLONG) or character (OCI_CLONG)...">OCI_LongGetSize</a>(lg));    }    <a class="code" href="group__g__init.html#g639706aa8e9689c7ebffc018fac6d3ae" title="Clean up all resources allocated by the library.">OCI_Cleanup</a>();    <span class="keywordflow">return</span> EXIT_SUCCESS;}</pre></div> </dd></dl><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT <a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#g040ec19ae09a29b34e0143e39ab30939">OCI_LongCreate</a> (<a class="el" href="struct_o_c_i___statement.html">OCI_Statement</a> *stmt, unsigned int type)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a local temporary Long instance.  <a href="#g040ec19ae09a29b34e0143e39ab30939"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT boolean OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#gdc23551bd5aa7832cbaee4e32a2b283a">OCI_LongFree</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Free a local temporary long.  <a href="#gdc23551bd5aa7832cbaee4e32a2b283a"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT unsigned int OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#g69ae3c008a5f540c4d7c6eca502b6898">OCI_LongGetType</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the type of the given Long object.  <a href="#g69ae3c008a5f540c4d7c6eca502b6898"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT unsigned int OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#gd7e0ba53269cc2d5aace557a984c8717">OCI_LongRead</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg, void *buffer, unsigned int len)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read a portion of a long into the given buffer [Obsolete].  <a href="#gd7e0ba53269cc2d5aace557a984c8717"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT unsigned int OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#g1a76c2c5de1c81d38be17bf28524ce99">OCI_LongWrite</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg, void *buffer, unsigned int len)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Write a buffer into a Long.  <a href="#g1a76c2c5de1c81d38be17bf28524ce99"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT unsigned int OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#gf7ed15bc901e38b9bc3394f334bf8d4c">OCI_LongGetSize</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the buffer size of a long object in bytes (OCI_BLONG) or character (OCI_CLONG).  <a href="#gf7ed15bc901e38b9bc3394f334bf8d4c"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">OCI_EXPORT void *OCI_API&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__g__long.html#gee33459c8a44c3216df4335627cac818">OCI_LongGetBuffer</a> (<a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *lg)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the internal buffer of an <a class="el" href="struct_o_c_i___long.html" title="Oracle Long datatype.">OCI_Long</a> object read from a fetch sequence.  <a href="#gee33459c8a44c3216df4335627cac818"></a><br></td></tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="g040ec19ae09a29b34e0143e39ab30939"></a><!-- doxytag: member="ocilib.h::OCI_LongCreate" ref="g040ec19ae09a29b34e0143e39ab30939" args="(OCI_Statement *stmt, unsigned int type)" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname">OCI_EXPORT <a class="el" href="struct_o_c_i___long.html">OCI_Long</a>* OCI_API OCI_LongCreate           </td>          <td>(</td>          <td class="paramtype"><a class="el" href="struct_o_c_i___statement.html">OCI_Statement</a> *&nbsp;</td>          <td class="paramname"> <em>stmt</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">unsigned int&nbsp;</td>          <td class="paramname"> <em>type</em></td><td>&nbsp;</td>        </tr>        <tr>          <td></td>          <td>)</td>          <td></td><td></td><td width="100%"></td>        </tr>      </table></div><div class="memdoc"><p>Create a local temporary Long instance. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>stmt</em>&nbsp;</td><td>- Statement handle </td></tr>    <tr><td valign="top"></td><td valign="top"><em>type</em>&nbsp;</td><td>- Long type</td></tr>  </table></dl>Supported lob types :<p><ul><li>OCI_BLONG : Binary Long</li><li>OCI_CLONG : Character Long</li></ul><p><dl class="return" compact><dt><b>Returns:</b></dt><dd>Return the long handle on success otherwise NULL on failure </dd></dl><p>Definition at line <a class="el" href="long_8c-source.html#l00087">87</a> of file <a class="el" href="long_8c-source.html">long.c</a>.</p></div></div><p><a class="anchor" name="gdc23551bd5aa7832cbaee4e32a2b283a"></a><!-- doxytag: member="ocilib.h::OCI_LongFree" ref="gdc23551bd5aa7832cbaee4e32a2b283a" args="(OCI_Long *lg)" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname">OCI_EXPORT boolean OCI_API OCI_LongFree           </td>          <td>(</td>          <td class="paramtype"><a class="el" href="struct_o_c_i___long.html">OCI_Long</a> *&nbsp;</td>          <td class="paramname"> <em>lg</em>          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"></td>        </tr>      </table></div><div class="memdoc"><p>Free a local temporary long. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>lg</em>&nbsp;</td><td>- Long handle</td></tr>  </table></dl><dl class="warning" compact><dt><b>Warning:</b></dt><dd>Only lobs created with <a class="el" href="group__g__long.html#g040ec19ae09a29b34e0143e39ab30939" title="Create a local temporary Long instance.">OCI_LongCreate()</a> should be freed by <a class="el" href="group__g__long.html#gdc23551bd5aa7832cbaee4e32a2b283a" title="Free a local temporary long.">OCI_LongFree()</a></dd></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>TRUE on success otherwise FALSE </dd></dl><p>Definition at line <a class="el" href="long_8c-source.html#l00106">106</a> of file <a class="el" href="long_8c-source.html">long.c</a>.</p><p>References <a class="el" href="ocilib__types_8h-source.html#l00484">OCI_Long::buffer</a>.</p></div></div><p><a class="anchor" name="gee33459c8a44c3216df4335627cac818"></a><!-- doxytag: member="ocilib.h::OCI_LongGetBuffer" ref="gee33459c8a44c3216df4335627cac818" args="(OCI_Long *lg)" --><div class="memitem"><div class="memproto">

⌨️ 快捷键说明

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