📄 group__g__demo.html
字号:
<span class="preprocessor">#if defined(OCI_CHARSET_UNICODE) && !defined(_WINDOWS)</span><span class="preprocessor"></span><span class="preprocessor"> #define print_mstr(x) printf("%ls", x)</span><span class="preprocessor"></span><span class="preprocessor">#else</span><span class="preprocessor"></span><span class="preprocessor"> #define print_mstr(x) print_mt(MT("%s"), x)</span><span class="preprocessor"></span><span class="preprocessor">#endif</span><span class="preprocessor"></span><span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * PROGRAM ARGUMENTS</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="preprocessor">#if defined(OCI_CHARSET_UNICODE)</span><span class="preprocessor"></span><span class="preprocessor"> #if defined(_MSC_VER)</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"> #define GET_ARG(s, i) mtsncat(s, argv[i], sizeof(s))</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_mstr(x)</span><span class="preprocessor"></span><span class="preprocessor"> #define GET_ARG(s, i) mbstowcs(s, argv[i], sizeof(s))</span><span class="preprocessor"></span><span class="preprocessor"> #endif</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"> #define GET_ARG(s, i) strncat(s, argv[i], sizeof(s))</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-2009 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="keywordtype">void</span> test_ref(<span class="keywordtype">void</span>);<span class="keywordtype">void</span> test_directpath(<span class="keywordtype">void</span>);<span class="comment">/* ocilib test functions array */</span>test_t tab_test[] ={ {test_format, TRUE}, {test_immediate, TRUE}, {test_immediate_format, TRUE}, {test_fetch, TRUE}, {test_bind1, TRUE}, {test_bind2, TRUE}, {test_piecewise_insert, TRUE}, {test_piecewise_fetch, TRUE}, {test_lob, TRUE}, {test_nested_table, TRUE}, {test_ref_cursor, TRUE}, {test_plsql, TRUE}, {test_dates, TRUE}, {test_timestamp, TRUE}, {test_describe, TRUE}, {test_returning, TRUE}, {test_returning_array, TRUE}, {test_object_insert, TRUE}, {test_object_fetch, TRUE}, {test_scrollable_cursor, TRUE}, {test_collection, TRUE}, {test_ref, TRUE}, {test_directpath, TRUE}};<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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -