📄 group__complex.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: The advanced interface.</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 Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <a class="qindex" href="examples.html">Examples</a></div><h1>The advanced interface.</h1>This functions offer more flexibility in terms of datatypes, but they need (much) more parameters. <a href="#_details">More...</a><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>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga0">sqlo_prepare</a> (<a class="el" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh, const char *stmt)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Parse a statement. <a href="#ga0"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga1">sqlo_bind_by_name</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, const char *name, int param_type, const void *param_addr, unsigned int param_size, short *ind_addr, int is_array)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Bind a variable by name. <a href="#ga1"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga2">sqlo_bind_ref_cursor</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, const char *cursor_name, int *sth2p)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Bind a REF CURSOR. <a href="#ga2"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga3">sqlo_bind_by_pos</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, int position, int param_type, const void *param_addr, unsigned int param_size, short *ind_addr, int is_array)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Bind a variable by position. <a href="#ga3"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga4">sqlo_bind_by_pos2</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, int position, int param_type, const void *param_addr, unsigned int param_size, short *ind_addr, unsigned short *rcode_addr, unsigned int skip_size)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Bind a variable by position. <a href="#ga4"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga5">sqlo_define_by_pos</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, int value_pos, int value_type, const void *value_addr, unsigned int value_size, short *ind_addr, short *rlen_addr, int is_array)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Define a output variable of the select list. <a href="#ga5"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga6">sqlo_define_by_pos2</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, int value_pos, int value_type, const void *value_addr, unsigned int value_size, short *ind_addr, unsigned short *rlen_addr, unsigned short *rcode_addr, unsigned int skip_size)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Define a output variable of the select list. <a href="#ga6"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga7">sqlo_define_ntable</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, unsigned int pos, int *sth2p)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Define a nested table Please visit the example for details. <a href="#ga7"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="group__complex.html#ga8">sqlo_execute</a> (<a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth, unsigned int iterations)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Execute a statement. <a href="#ga8"></a><br><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This functions offer more flexibility in terms of datatypes, but they need (much) more parameters. <p>Use these functions if you want to execute PL/SQL or stored procedures. <hr><h2>Function Documentation</h2><a class="anchor" name="ga1" doxytag="sqlora.h::sqlo_bind_by_name" ></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_bind_by_name </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> </td> <td class="mdname" nowrap> <em>sth</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const char * </td> <td class="mdname" nowrap> <em>name</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>param_type</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const void * </td> <td class="mdname" nowrap> <em>param_addr</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>param_size</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>short * </td> <td class="mdname" nowrap> <em>ind_addr</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>is_array</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>Bind a variable by name. <p>Use this to bind a variable in a query or a stored procedure call.<p>If is_array is 1, the parameters param_addr and ind_addr must point to arrays. ind_addr is optional and can be passed a NULL. The param_size is still the size of one array element, not the whole array size!<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>sth</em> </td><td>I - The statement handle. </td></tr> <tr><td valign=top><em>name</em> </td><td>I - The bind parameter name. </td></tr> <tr><td valign=top><em>param_type</em> </td><td>I - The datatype of the bind parameter (see <a class="el" href="group__constants.html#ga6">sqlo_data_types</a>). </td></tr> <tr><td valign=top><em>param_addr</em> </td><td>I - The address of a variable or array. </td></tr> <tr><td valign=top><em>param_size</em> </td><td>I - The size of the object at param_addr in bytes. </td></tr> <tr><td valign=top><em>ind_addr</em> </td><td>I - The pointer to the NULL indicator variable (optional). </td></tr> <tr><td valign=top><em>is_array</em> </td><td>I - 1 means param_addr points to an array, 0 means a single variable.</td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd><ul><li>SQLO_SUCCESS </li><li>< 0 on error </li></ul></dd></dl><dl compact><dt><b>Example:</b></dt><dd><div class="fragment"><pre><span class="comment">/* $Id: ex9.c,v 1.5 2002/08/24 12:54:47 kpoitschke Exp $ */</span><span class="preprocessor">#include <stdio.h></span><span class="preprocessor">#include <stdlib.h></span><span class="preprocessor">#include "examples.h"</span><span class="keyword">static</span> <span class="keywordtype">void</span> create_sp __P((<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh));<span class="keywordtype">int</span> call_plsql(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh){ <span class="keywordtype">double</span> ip1; <span class="keywordtype">int</span> ip2; <span class="keywordtype">char</span> op[80]; <a class="code" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth = <a class="code" href="group__constants.html#gga5a49">SQLO_STH_INIT</a>; <span class="comment">/* the stored procecdure call */</span> <span class="keywordtype">char</span> * stmt = <span class="stringliteral">"BEGIN\n"</span> <span class="stringliteral">" EX9(:ip1, :ip2, :op);\n"</span> <span class="stringliteral">"END;\n"</span>; create_sp(dbh); <span class="comment">/* create the test stored procedure */</span> ip1 = 1.5; ip2 = 20; <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))) { <span class="comment">/* bind all 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#ga187">sqlo_bind_by_name</a>(sth, <span class="stringliteral">":ip1"</span>, SQLOT_FLT, &ip1, <span class="keyword">sizeof</span>(ip1), 0, 0) || <a class="code" href="group__complex.html#ga187">sqlo_bind_by_name</a>(sth, <span class="stringliteral">":ip2"</span>, SQLOT_INT, &ip2, <span class="keyword">sizeof</span>(ip2), 0, 0) || <a class="code" href="group__complex.html#ga187">sqlo_bind_by_name</a>(sth, <span class="stringliteral">":op"</span>, SQLOT_STR, &op, <span class="keyword">sizeof</span>(op), 0, 0) )) { error_exit(dbh, <span class="stringliteral">"sqlo_bind_by_name"</span>); } <span class="keywordflow">else</span> { <span class="comment">/* execute the call */</span> <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__complex.html#ga194">sqlo_execute</a>(sth, 1)) error_exit(dbh, <span class="stringliteral">"sqlo_execute"</span>); } <span class="comment">/* print the result */</span> <span class="keywordflow">if</span> (atof(op) != (ip1 + ip2)) printf(<span class="stringliteral">"Stored procudure returned wrong result %s, expected %6.2f\n"</span>, op, (ip1 + ip2)); <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth)) error_exit(dbh, <span class="stringliteral">"sqlo_execute"</span>); } <span class="keywordflow">else</span> { error_exit(dbh, <span class="stringliteral">"sqlo_prepare"</span>); } <span class="keywordflow">if</span> ( 0 > <a class="code" href="group__easy.html#ga163">sqlo_exec</a>(dbh, <span class="stringliteral">"DROP PROCEDURE EX9"</span>)) error_exit(dbh, <span class="stringliteral">"sqlo_exec"</span>); <span class="keywordflow">return</span> 1;}<span class="comment">/* creates the stored procedure used above */</span><span class="keyword">static</span> <span class="keywordtype">void</span>create_sp(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh){ <span class="keywordtype">char</span> * stmt = <span class="stringliteral">"CREATE OR REPLACE PROCEDURE EX9(ipNum1 IN NUMBER, ipNum2 IN NUMBER, opStr OUT VARCHAR)\n"</span> <span class="stringliteral">"IS\n"</span> <span class="stringliteral">"BEGIN\n"</span> <span class="stringliteral">" opStr := TO_CHAR(ipNum1 + ipNum2);\n"</span> <span class="stringliteral">"END;\n"</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, stmt);}<span class="comment">/* $Id: ex9.c,v 1.5 2002/08/24 12:54:47 kpoitschke Exp $ */</span></pre></div></dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__complex.html#ga0">sqlo_prepare</a>, <a class="el" href="group__complex.html#ga3">sqlo_bind_by_pos</a>, <a class="el" href="group__complex.html#ga5">sqlo_define_by_pos</a> </dd></dl><p>Definition at line <a class="el" href="sqlora_8c-source.html#l06481">6481</a> of file <a class="el" href="sqlora_8c-source.html">sqlora.c</a>.<p>References <a class="el" href="sqlora_8c-source.html#l02045">_alloc_bindp()</a>, <a class="el" href="sqlora_8c-source.html#l02822">_get_data_type_str()</a>, <a class="el" href="sqlora_8c-source.html#l04319">_get_trace_fp()</a>, <a class="el" href="sqlora_8c-source.html#l02785">_is_prepared()</a>, <a class="el" href="sqlora_8c-source.html#l00575">_sqlo_stmt_struct::bindpv</a>, <a class="el" href="sqlora_8c-source.html#l00579">_sqlo_stmt_struct::bindpv_size</a>, <a class="el" href="sqlora_8c-source.html#l00416">CHECK_OCI_STATUS_RETURN</a>, <a class="el" href="sqlora_8c-source.html#l00367">CHECK_STHANDLE</a>, <a class="el" href="sqlora_8c-source.html#l00565">_sqlo_stmt_struct::dbp</a>, <a class="el" href="sqlora_8c-source.html#l00483">_sqlo_db_struct::errhp</a>, <a class="el" href="sqlora_8c-source.html#l00577">_sqlo_stmt_struct::num_bindpv</a>, <a class="el" href="group__complex.html#ga2">sqlo_bind_ref_cursor()</a>, <a class="el" href="sqlora_8c.html#a30">sqlo_db_struct_ptr_t</a>, <a class="el" href="group__constants.html#gga4a36">SQLO_INVALID_STMT_HANDLE</a>, <a class="el" href="group__constants.html#gga4a39">SQLO_STMT_NOT_PARSED</a>, <a class="el" href="sqlora_8c.html#a35">sqlo_stmt_struct_ptr_t</a>, <a class="el" href="group__constants.html#gga6a85">SQLOT_RSET</a>, <a class="el" href="sqlora_8c-source.html#l00493">_sqlo_db_struct::status</a>, <a class="el" href="sqlora_8c-source.html#l00567">_sqlo_stmt_struct::stmthp</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__complex_ga1_cgraph.png" border="0" usemap="#group__complex_ga1_cgraph_map" alt=""></center><map name="group__complex_ga1_cgraph_map"><area href="sqlora_8c.html#a124" shape="rect" coords="227,5,315,24" alt="">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -