📄 group__g__demo.html
字号:
<span class="comment"> * PROGRAM ARGUMENTS</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="preprocessor">#if defined(_WINDOWS) && defined(OCI_CHARSET_UNICODE)</span><span class="preprocessor"></span><span class="preprocessor"> #define mtmain wmain</span><span class="preprocessor"></span><span class="preprocessor"> #define mtarg mtext</span><span class="preprocessor"></span><span class="preprocessor"> #define print_args(x) print_mt(x)</span><span class="preprocessor"></span><span class="preprocessor">#else</span><span class="preprocessor"></span><span class="preprocessor"> #define mtmain main</span><span class="preprocessor"></span><span class="preprocessor"> #define mtarg char</span><span class="preprocessor"></span><span class="preprocessor"> #define print_args(x) print_text(x)</span><span class="preprocessor"></span><span class="preprocessor">#endif</span><span class="preprocessor"></span></pre></div><p>Portable Main demo application source <div class="fragment"><pre class="fragment"><span class="comment">/*</span><span class="comment"> +----------------------------------------------------------------------+ </span><span class="comment"> | |</span><span class="comment"> | OCILIB - C Driver for Oracle |</span><span class="comment"> | |</span><span class="comment"> | (C Wrapper for Oracle OCI) |</span><span class="comment"> | |</span><span class="comment"> | DEMO SOURCE FILE |</span><span class="comment"> | |</span><span class="comment"> +----------------------------------------------------------------------+</span><span class="comment"> | Website : http://orclib.sourceforge.net |</span><span class="comment"> +----------------------------------------------------------------------+</span><span class="comment"> | Copyright (c) 2007-2008 Vincent ROGIER <vince.rogier@gmail.com> |</span><span class="comment"> +----------------------------------------------------------------------+</span><span class="comment"> | This library is free software; you can redistribute it and/or |</span><span class="comment"> | modify it under the terms of the GNU Library General Public |</span><span class="comment"> | License as published by the Free Software Foundation; either |</span><span class="comment"> | version 2 of the License, or (at your option) any later version. |</span><span class="comment"> | |</span><span class="comment"> | This library is distributed in the hope that it will be useful, |</span><span class="comment"> | but WITHOUT ANY WARRANTY; without even the implied warranty of |</span><span class="comment"> | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |</span><span class="comment"> | Library General Public License for more details. |</span><span class="comment"> | |</span><span class="comment"> | You should have received a copy of the GNU Library General Public |</span><span class="comment"> | License along with this library; if not, write to the Free |</span><span class="comment"> | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |</span><span class="comment"> +----------------------------------------------------------------------+</span><span class="comment"> | Author: Vincent ROGIER <vince.rogier@gmail.com> |</span><span class="comment"> +----------------------------------------------------------------------+ </span><span class="comment"></span><span class="comment">*/</span><span class="preprocessor">#include "ocilib_demo.h"</span><span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * prototypes</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> err_handler(<a class="code" href="struct_o_c_i___error.html" title="Encapsulates an Oracle or OCILIB exception.">OCI_Error</a> *err);<span class="keywordtype">void</span> print_version(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> cleanup(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> disconnect(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> create_tables(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> drop_tables(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_format(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_immediate(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_immediate_format(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_fetch(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_bind1(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_bind2(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_piecewise_insert(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_piecewise_fetch(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_lob(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_nested_table(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_ref_cursor(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_plsql(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_dates(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_timestamp(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_describe(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_returning(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_returning_array(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_object_insert(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_object_fetch(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_scrollable_cursor(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_collection(<span class="keywordtype">void</span>);<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * variables</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keyword">static</span> <a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *cn = NULL;<span class="keyword">static</span> <a class="code" href="struct_o_c_i___statement.html" title="Oracle SQL or PL/SQL statement.">OCI_Statement</a> *st = NULL;<span class="keyword">static</span> <a class="code" href="struct_o_c_i___resultset.html" title="Collection of output columns from a select statement.">OCI_Resultset</a> *rs = NULL;<span class="keyword">static</span> mtext str[SIZE_STR+1];<span class="keyword">static</span> dtext temp[SIZE_STR+1];<span class="keyword">static</span> <span class="keywordtype">int</span> nb_err = 0;<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * err_handler</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> err_handler(<a class="code" href="struct_o_c_i___error.html" title="Encapsulates an Oracle or OCILIB exception.">OCI_Error</a> *err){ print_text(<span class="stringliteral">"\n"</span>); <span class="keywordflow">if</span> (<a class="code" href="group__g__error.html#g66d447c8cd06ea3f841b439a1aac055b" title="Retrieve the type of error from error handle.">OCI_ErrorGetType</a>(err) == OCI_ERR_ORACLE) { <span class="keyword">const</span> mtext *sql = <a class="code" href="group__g__exec.html#g05c6c5af87cdff3a231755cfd44e133f" title="Return the last SQL or PL/SQL statement parsed by the statement.">OCI_GetSql</a>(<a class="code" href="group__g__error.html#gb099d59cd4faf2fa6a4430114ea73402" title="Retrieve statement handle within the error occured.">OCI_ErrorGetStatement</a>(err)); <span class="keywordflow">if</span> (sql != NULL) { print_text(<span class="stringliteral">"> ERROR - SQL : "</span>); print_mstr(sql); print_text(<span class="stringliteral">"\n"</span>); } } print_text(<span class="stringliteral">"> ERROR - MSG : "</span>); print_mstr(<a class="code" href="group__g__error.html#ga06418c61c432aaaa725fecdd28bcb96" title="Retrieve error message from error handle.">OCI_ErrorGetString</a>(err)); print_text(<span class="stringliteral">"\n"</span>); nb_err++;} <span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * main</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">int</span> mtmain(<span class="keywordtype">int</span> argc, mtarg* argv[]){ <span class="comment">/* CHECK COMMAND LINE --------------------------------------------------- */</span> <span class="keywordflow">if</span> (argc < (ARG_COUNT-1)) { <span class="keywordflow">return</span> EXIT_FAILURE; } <span class="comment">/* INITIALIZE OCI ------------------------------------------------------- */</span> <span class="keywordflow">if</span> (!<a class="code" href="group__g__init.html#gcdb642d75f7c8478e083634144bc813c" title="Initializes the library.">OCI_Initialize</a>(err_handler, (argc==ARG_COUNT) ? argv[ARG_HOME]:NULL, OCI_ENV_DEFAULT)) <span class="keywordflow">return</span> EXIT_FAILURE; <span class="comment">/* CONNECTION TO SERVER ------------------------------------------------- */</span> print_text(<span class="stringliteral">"Connecting to "</span>); print_args(argv[ARG_USER]); print_text(<span class="stringliteral">"/"</span>); print_args(argv[ARG_PWD]); print_text(<span class="stringliteral">"@"</span>); print_args(argv[ARG_DB]); print_text(<span class="stringliteral">"\n\n"</span>); cn = <a class="code" href="group__g__connect.html#gdb6e2cdf759587dd81c2fda7c5f44338" title="Create a physical connection to an Oracle database server.">OCI_ConnectionCreate</a>(argv[ARG_DB], argv[ARG_USER], argv[ARG_PWD], OCI_SESSION_DEFAULT); <span class="keywordflow">if</span> (cn) { st = <a class="code" href="group__g__exec.html#g335822f983af0fb5c529431f06a9a17b" title="Create a statement object and return its handle.">OCI_StatementCreate</a>(cn); print_version(); create_tables(); test_format();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -