📄 group__init.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: Initialization</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>Initialization</h1><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__init.html#ga0">sqlo_init</a> (int threaded_mode, unsigned int max_db, unsigned int max_cursors)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Init the library. <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__init.html#ga1">sqlo_version</a> (const char *version_str)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Checks if the version is sufficient. <a href="#ga1"></a><br><br></td></tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="ga0" doxytag="sqlora.h::sqlo_init" ></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_init </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>threaded_mode</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>max_db</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>max_cursors</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>Init the library. <p>Reads the environment and sets up the global variables for trace-level/-file, and arraysize. Initializes the OCI library. This is the first function you should call, before you use the library. Make sure you call it only once!<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>threaded_mode</em> </td><td>I - SQLO_ON threading enabled, SQLO_OFF threading disabled. </td></tr> <tr><td valign=top><em>max_db</em> </td><td>I - The maximum number of parallel connections (max. 32767) </td></tr> <tr><td valign=top><em>max_cursors</em> </td><td>I - The maximum number of open cursors per connection (max. 65535).</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: examples.c,v 1.6 2004/01/03 16:48:19 kpoitschke Exp $ */</span><span class="preprocessor">#include <stdio.h></span><span class="preprocessor">#include <stdlib.h></span><span class="preprocessor">#include "<a class="code" href="sqlora_8h.html">sqlora.h</a>"</span><span class="preprocessor">#include "examples.h"</span><span class="keyword">static</span> CONST <span class="keywordtype">char</span> * _defuser = <span class="stringliteral">"scott/tiger"</span>;<span class="keyword">static</span> <span class="keywordtype">int</span> _abort_flag = 0;<span class="keywordtype">void</span> sigint_handler(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> sigint_handler(<span class="keywordtype">void</span>) { printf(<span class="stringliteral">"Catched SIGINT\n"</span>); _abort_flag++;}<span class="preprocessor">#define RETURN_ON_ABORT if (_abort_flag) { sqlo_rollback(dbh); return EXIT_FAILURE; }</span><span class="preprocessor"></span><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv){ CONST <span class="keywordtype">char</span> * cstr = _defuser; <a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh; <span class="keywordtype">int</span> stat; <a class="code" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth; <span class="keywordtype">double</span> min_income; <span class="keywordtype">char</span> server_version[1024]; <span class="keywordtype">int</span> handle; <span class="comment">/* handle of the interrupt handler */</span> <span class="keywordflow">if</span> (argc > 1) cstr = argv[1]; <span class="comment">/* init */</span> <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__init.html#ga0">sqlo_init</a>(SQLO_OFF, 1, 100)) { printf(<span class="stringliteral">"Failed to init libsqlora8\n"</span>); <span class="keywordflow">return</span> EXIT_FAILURE; } <span class="comment">/* register the interrupt handler */</span> <a class="code" href="group__misc.html#ga216">sqlo_register_int_handler</a>(&handle, sigint_handler); <span class="comment">/* login */</span> <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__loginout.html#ga180">sqlo_connect</a>(&dbh, cstr)) { printf(<span class="stringliteral">"Cannot login with %s\n"</span>, cstr); <span class="keywordflow">return</span> EXIT_FAILURE; } RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="keywordflow">if</span> (<a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a class="code" href="group__misc.html#ga214">sqlo_server_version</a>(dbh, server_version, <span class="keyword">sizeof</span>(server_version))) { printf(<span class="stringliteral">"Failed to get the server version: %s\n"</span>, <a class="code" href="group__error.html#ga158">sqlo_geterror</a>(dbh)); <span class="keywordflow">return</span> EXIT_FAILURE; } printf(<span class="stringliteral">"Connected to:\n%s\n\n"</span>, server_version); RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="comment">/* ex1.c */</span> <span class="keywordflow">if</span> (!table_exists(dbh, <span class="stringliteral">"EMP"</span>)) { printf(<span class="stringliteral">"Table EMP does not exist. Please install Oracle demo tables\n"</span>); <span class="keywordflow">return</span> EXIT_FAILURE; } RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="comment">/* ex2.c */</span> <span class="comment">/* EMP should have 8 columns */</span> <span class="keywordflow">if</span> ( 8 != (stat = col_count(dbh, <span class="stringliteral">"EMP"</span>))) printf(<span class="stringliteral">"Expected 8 columns in EMP, but counted %d\n"</span>, stat); RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="comment">/* ex3.c */</span> stat = update_manager(dbh); printf(<span class="stringliteral">"Reduced the salary of %d managers\n"</span>, stat); <a class="code" href="group__transactions.html#ga184">sqlo_rollback</a>(dbh); RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="comment">/* ex4.c */</span> sth = open_cursor(dbh); <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth); RETURN_ON_ABORT; <span class="comment">/* finish if SIGINT was catched */</span> <span class="comment">/* ex5.c */</span> sth = open_cursor2(dbh, 2500.0); <a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -