📄 group__g__demo.html
字号:
MT(<span class="stringliteral">" val_flt float, "</span>) MT(<span class="stringliteral">" val_str varchar2(30), "</span>) MT(<span class="stringliteral">" val_date date, "</span>) MT(<span class="stringliteral">" val_lob clob, "</span>) MT(<span class="stringliteral">" val_file bfile, "</span>) MT(<span class="stringliteral">" val_obj type_t, "</span>) MT(<span class="stringliteral">" val_raw raw(20) "</span>) MT(<span class="stringliteral">")"</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, MT(<span class="stringliteral">"create type t_tab1_emp as VARRAY(100) of varchar2(50)"</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, MT(<span class="stringliteral">"create type t_tab2_emp as table of varchar2(50)"</span>)); <span class="comment">/* create table for the demo */</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, MT(<span class="stringliteral">"create table test_fetch(code int, article "</span>) MT(<span class="stringliteral">"varchar2(30), price float, creation date)"</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, MT(<span class="stringliteral">"create table test_long_raw(code int, content long raw)"</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, MT(<span class="stringliteral">"create table test_long_str(code int, content long)"</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, MT(<span class="stringliteral">"create table test_lob(code int, content CLOB)"</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, MT(<span class="stringliteral">"create table test_object(val test_t)"</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, MT(<span class="stringliteral">"create table test_table_obj of type_t"</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, MT(<span class="stringliteral">"create table test_array "</span>) MT(<span class="stringliteral">"( "</span>) MT(<span class="stringliteral">" val_int number, "</span>) MT(<span class="stringliteral">" val_flt float, "</span>) MT(<span class="stringliteral">" val_str varchar2(30), "</span>) MT(<span class="stringliteral">" val_date date, "</span>) MT(<span class="stringliteral">" val_lob clob, "</span>) MT(<span class="stringliteral">" val_file bfile "</span>) MT(<span class="stringliteral">")"</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, MT(<span class="stringliteral">"create table test_coll_varray "</span>) MT(<span class="stringliteral">"( "</span>) MT(<span class="stringliteral">" departement number, "</span>) MT(<span class="stringliteral">" employees t_tab1_emp "</span>) MT(<span class="stringliteral">")"</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, MT(<span class="stringliteral">"create table test_coll_nested "</span>) MT(<span class="stringliteral">"( "</span>) MT(<span class="stringliteral">" departement number, "</span>) MT(<span class="stringliteral">" employees t_tab2_emp "</span>) MT(<span class="stringliteral">") nested table employees store as test_table_emp"</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, MT(<span class="stringliteral">"create table test_directpath(val_int number(8,4), "</span>) MT(<span class="stringliteral">" val_str varchar2(30), val_date date)"</span>)); <span class="comment">/* insert data into the demo tables */</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, MT(<span class="stringliteral">"insert into test_fetch "</span>) MT(<span class="stringliteral">"(code, article, price, creation) "</span>) MT(<span class="stringliteral">"values (1, 'shoes', 3.14, to_date('1978-12-23', 'YYYY-MM-DD'))"</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, MT(<span class="stringliteral">"insert into test_fetch "</span>) MT(<span class="stringliteral">"(code, article, price, creation) "</span>) MT(<span class="stringliteral">"values (2, 'shirt', 5.99, to_date('1999-09-12', 'YYYY-MM-DD'))"</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, MT(<span class="stringliteral">"insert into test_lob(code,content) "</span>) MT(<span class="stringliteral">"values (1, EMPTY_CLOB())"</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, MT(<span class="stringliteral">"insert into test_long_str(code,content) "</span>) MT(<span class="stringliteral">"values (1, 'Rugby rocks !')"</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, MT(<span class="stringliteral">"insert into test_coll_varray(departement,employees) "</span>) MT(<span class="stringliteral">"values (1, t_tab1_emp('Peter', 'John', 'Paula', 'Gina'))"</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, MT(<span class="stringliteral">"insert into test_coll_varray(departement,employees) "</span>) MT(<span class="stringliteral">"values (2, t_tab1_emp('Ben', 'Alice', 'Joel', 'Maria'))"</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, MT(<span class="stringliteral">"insert into test_coll_nested(departement,employees) "</span>) MT(<span class="stringliteral">"values (1, t_tab2_emp('Vince', 'Richard', 'Rita', 'Sophia'))"</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, MT(<span class="stringliteral">"insert into test_coll_nested(departement,employees) "</span>) MT(<span class="stringliteral">"values (2, t_tab2_emp('Paul', 'Sarah', 'Robert', 'Zoe'))"</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, MT(<span class="stringliteral">"insert into test_table_obj values(type_t(1, 'shoes'))"</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, MT(<span class="stringliteral">"insert into test_table_obj values(type_t(2, 'pen'))"</span>)); <a class="code" href="group__g__transac.html#gee1ba614ed2dc5bd83bf788ca08f3e71" title="Commit current pending changes.">OCI_Commit</a>(cn);}<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * drop_tables</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> drop_tables(<span class="keywordtype">void</span>){ print_text(<span class="stringliteral">"\n>>>>> DROPPING TABLES AND TYPES \n\n"</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, MT(<span class="stringliteral">"drop table test_fetch"</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, MT(<span class="stringliteral">"drop table test_long_str"</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, MT(<span class="stringliteral">"drop table test_long_raw"</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, MT(<span class="stringliteral">"drop table test_lob"</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, MT(<span class="stringliteral">"drop table test_array"</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, MT(<span class="stringliteral">"drop table test_object"</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, MT(<span class="stringliteral">"drop table test_coll_varray"</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, MT(<span class="stringliteral">"drop table test_coll_nested"</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, MT(<span class="stringliteral">"drop table test_table_obj"</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, MT(<span class="stringliteral">"drop table test_directpath"</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, MT(<span class="stringliteral">"drop type test_t"</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, MT(<span class="stringliteral">"drop type type_t"</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, MT(<span class="stringliteral">"drop type t_tab1_emp"</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, MT(<span class="stringliteral">"drop type t_tab2_emp"</span>));}<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * test_format</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> test_format(<span class="keywordtype">void</span>){ <span class="keywordtype">int</span> code = 1; print_text(<span class="stringliteral">"\n>>>>> TEST FORMATTING \n\n"</span>); <a class="code" href="group__g__format.html#ge1b4805b4ed6530b496cd637b52a2adf" title="Parse and execute a formatted SQL statement or PL/SQL block.">OCI_ExecuteStmtFmt</a>(st, MT(<span class="stringliteral">"select * from test_fetch where code = %i"</span>), code); 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="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs)) { print_frmt(<span class="stringliteral">"> code : %i"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1)); print_text(<span class="stringliteral">", action : "</span>); print_dstr(<a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2)); print_frmt(<span class="stringliteral">", price : %g"</span>, <a class="code" href="group__g__fetch.html#gdfbe8b6c23200810823e9ca6a1956cd7" title="Return the current double value of the column at the given index in the resultset...">OCI_GetDouble</a>(rs,3)); print_text(<span class="stringliteral">", date : "</span>); print_dstr(<a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 4)); print_text(<span class="stringliteral">"\n"</span>); } print_frmt(<span class="stringliteral">"\n%d row(s) fetched\n"</span>, <a class="code" href="group__g__fetch.html#g93bd9197720088dbda2bef593ad1c07c" title="Retrieve the number of rows fetched so far.">OCI_GetRowCount</a>(rs));}<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * test_immediate</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> test_immediate(<span class="keywordtype">void</span>){ <span class="keywordtype">int</span> code = 1; print_text(<span class="stringliteral">"\n>>>>> TEST IMMEDIATE \n\n"</span>); <a class="code" href="group__g__format.html#g85318e359913e49d5654d2f53a070ef7" title="Perform 3 calls (prepare+execute+fetch) in 1 call.">OCI_Immediate</a>(cn, MT(<span class="stringliteral">"select code, article from test_fetch where code = 1"</span>), OCI_ARG_INT, &code, OCI_ARG_TEXT, temp); print_frmt(<span class="stringliteral">"> code : %i "</span>, code); print_text(<span class="stringliteral">"- article : "</span>); print_dstr(temp); print_text(<span class="stringliteral">"\n"</span>);}<span class="comment">/* ------------------------------------------------------------------------ *</span><span class="comment"> * test_immediate_format</span><span class="comment"> * ------------------------------------------------------------------------ */</span><span class="keywordtype">void</span> test_immediate_format(<span class="keywordtype">void</span>){ <span class="keywordtype">int</span> code = 1; print_text(<span class="stringliteral">"\n>>>>> TEST IMMEDIATE FORMATTED\n\n"</span>); <a class="code" href="group__g__format.html#g845524c6dce7499a0cc27488052a93c2" title="Performs 4 call (prepare+bind+execute+fetch) in 1 call.">OCI_ImmediateFmt</a>(cn, MT(<span class="stringliteral">"select article from test_fetch where code = %i"</span>), code, OCI_ARG_TEXT, temp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -