📄 collection_8c-source.html
字号:
<a name="l00122"></a>00122 <span class="comment">/* ************************************************************************ *</span><a name="l00123"></a>00123 <span class="comment"> * PUBLIC FUNCTIONS</span><a name="l00124"></a>00124 <span class="comment"> * ************************************************************************ */</span><a name="l00125"></a>00125 <a name="l00126"></a>00126 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00127"></a>00127 <span class="comment"> * OCI_CollCreate</span><a name="l00128"></a>00128 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00129"></a>00129 <a name="l00130"></a><a class="code" href="group__g__collection.html#ga2c5c18fa416fe1f955ccb5dbff43046">00130</a> <a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> * OCI_API <a class="code" href="group__g__collection.html#ga2c5c18fa416fe1f955ccb5dbff43046" title="Create a local collection instance.">OCI_CollCreate</a>(<a class="code" href="struct_o_c_i___type_info.html" title="Type info metadata handle.">OCI_TypeInfo</a> *typinf)<a name="l00131"></a>00131 {<a name="l00132"></a>00132 <a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll = NULL;<a name="l00133"></a>00133 <a name="l00134"></a>00134 OCI_CHECK_INITIALIZED(NULL);<a name="l00135"></a>00135 <a name="l00136"></a>00136 OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf, NULL);<a name="l00137"></a>00137 OCI_CHECK(typinf->ccode == OCI_UNKNOWN, NULL)<a name="l00138"></a>00138 <a name="l00139"></a>00139 coll = OCI_CollInit(typinf->con, &coll, (OCIColl *) NULL, typinf);<a name="l00140"></a>00140 <a name="l00141"></a>00141 OCI_RESULT(coll != NULL);<a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="keywordflow">return</span> coll;<a name="l00144"></a>00144 }<a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00147"></a>00147 <span class="comment"> * OCI_CollFree</span><a name="l00148"></a>00148 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00149"></a>00149 <a name="l00150"></a><a class="code" href="group__g__collection.html#g8663babe980c99ff0441feedff973912">00150</a> <span class="keywordtype">boolean</span> OCI_API <a class="code" href="group__g__collection.html#g8663babe980c99ff0441feedff973912" title="Free a local collection.">OCI_CollFree</a>(<a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll)<a name="l00151"></a>00151 {<a name="l00152"></a>00152 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll, FALSE);<a name="l00153"></a>00153 OCI_CHECK_OBJECT_FETCHED(coll, FALSE);<a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="comment">/* free data element accessor */</span><a name="l00156"></a>00156 <a name="l00157"></a>00157 <span class="keywordflow">if</span> (coll-><a class="code" href="struct_o_c_i___coll.html#7d09c118ff0a39a1987405a26593136e">elem</a> != NULL)<a name="l00158"></a>00158 {<a name="l00159"></a>00159 coll-><a class="code" href="struct_o_c_i___coll.html#7d09c118ff0a39a1987405a26593136e">elem</a>-><a class="code" href="struct_o_c_i___elem.html#4bcbd04ee1289266c4184d838d4b0558">hstate</a> = OCI_OBJECT_FETCHED_DIRTY;<a name="l00160"></a>00160 <a class="code" href="group__g__collection.html#gdf1010d812aa53c3b27d991fa47b4f98" title="Free a local collection element.">OCI_ElemFree</a>(coll-><a class="code" href="struct_o_c_i___coll.html#7d09c118ff0a39a1987405a26593136e">elem</a>);<a name="l00161"></a>00161 coll-><a class="code" href="struct_o_c_i___coll.html#7d09c118ff0a39a1987405a26593136e">elem</a> = NULL;<a name="l00162"></a>00162 }<a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="comment">/* create collection for local object */</span><a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="keywordflow">if</span> (coll-><a class="code" href="struct_o_c_i___coll.html#ab5e919829343ed52c8ecbc6415a95b5">hstate</a> == OCI_OBJECT_ALLOCATED)<a name="l00167"></a>00167 {<a name="l00168"></a>00168 OCI_OCIObjectFree(OCILib.env, coll-><a class="code" href="struct_o_c_i___coll.html#868c64c81b8bf3ca88c7ca8a6e57af03">typinf</a>-><a class="code" href="struct_o_c_i___type_info.html#ca5def6c7af066b4e23d8c66b78a2f6b">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>,<a name="l00169"></a>00169 coll-><a class="code" href="struct_o_c_i___coll.html#cd0eeebc9c44bcabe4a2ef626d94bef1">handle</a>, OCI_OBJECTFREE_NONULL);<a name="l00170"></a>00170 }<a name="l00171"></a>00171 <a name="l00172"></a>00172 OCI_FREE(coll);<a name="l00173"></a>00173 <a name="l00174"></a>00174 OCI_RESULT(TRUE);<a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="keywordflow">return</span> TRUE;<a name="l00177"></a>00177 }<a name="l00178"></a>00178 <a name="l00179"></a>00179 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00180"></a>00180 <span class="comment"> * OCI_CollAssign</span><a name="l00181"></a>00181 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00182"></a>00182 <a name="l00183"></a><a class="code" href="group__g__collection.html#g5121ce70006885b5f45df2c764ec8d8e">00183</a> <span class="keywordtype">boolean</span> OCI_API <a class="code" href="group__g__collection.html#g5121ce70006885b5f45df2c764ec8d8e" title="Assign a collection to another one.">OCI_CollAssign</a>(<a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll, <a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll_src)<a name="l00184"></a>00184 {<a name="l00185"></a>00185 <span class="keywordtype">boolean</span> res = TRUE;<a name="l00186"></a>00186 <a name="l00187"></a>00187 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll, FALSE);<a name="l00188"></a>00188 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll_src, FALSE);<a name="l00189"></a>00189 <a name="l00190"></a>00190 OCI_CHECK_COMPAT(coll-><a class="code" href="struct_o_c_i___coll.html#7b4f1aa1b566e2e8d4e62844991aeed5">con</a>,<a name="l00191"></a>00191 coll-><a class="code" href="struct_o_c_i___coll.html#868c64c81b8bf3ca88c7ca8a6e57af03">typinf</a>-><a class="code" href="struct_o_c_i___type_info.html#30783a0a4a5d15db8f8bfe90250f18a7">cols</a>[0].<a class="code" href="struct_o_c_i___column.html#ad9396e5095db31c838023313a41569e">icode</a> == coll_src-><a class="code" href="struct_o_c_i___coll.html#868c64c81b8bf3ca88c7ca8a6e57af03">typinf</a>-><a class="code" href="struct_o_c_i___type_info.html#30783a0a4a5d15db8f8bfe90250f18a7">cols</a>[0].<a class="code" href="struct_o_c_i___column.html#ad9396e5095db31c838023313a41569e">icode</a>,<a name="l00192"></a>00192 FALSE);<a name="l00193"></a>00193 <a name="l00194"></a>00194 OCI_CALL2<a name="l00195"></a>00195 (<a name="l00196"></a>00196 res, coll-><a class="code" href="struct_o_c_i___coll.html#7b4f1aa1b566e2e8d4e62844991aeed5">con</a>,<a name="l00197"></a>00197 <a name="l00198"></a>00198 OCICollAssign(OCILib.env, coll-><a class="code" href="struct_o_c_i___coll.html#7b4f1aa1b566e2e8d4e62844991aeed5">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, coll-><a class="code" href="struct_o_c_i___coll.html#cd0eeebc9c44bcabe4a2ef626d94bef1">handle</a>, coll_src-><a class="code" href="struct_o_c_i___coll.html#cd0eeebc9c44bcabe4a2ef626d94bef1">handle</a>)<a name="l00199"></a>00199 )<a name="l00200"></a>00200 <a name="l00201"></a>00201 OCI_CollGetInternalSize(coll);<a name="l00202"></a>00202 <a name="l00203"></a>00203 OCI_RESULT(res);<a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="keywordflow">return</span> res;<a name="l00206"></a>00206 }<a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00209"></a>00209 <span class="comment"> * OCI_CollGetType</span><a name="l00210"></a>00210 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00211"></a>00211 <a name="l00212"></a><a class="code" href="group__g__collection.html#g18518027318ac527c9cbefab4f16b7ba">00212</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> OCI_API <a class="code" href="group__g__collection.html#g18518027318ac527c9cbefab4f16b7ba" title="Return the collection type.">OCI_CollGetType</a>(<a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll)<a name="l00213"></a>00213 {<a name="l00214"></a>00214 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> type = OCI_UNKNOWN;<a name="l00215"></a>00215 <a name="l00216"></a>00216 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll, OCI_UNKNOWN);<a name="l00217"></a>00217 <a name="l00218"></a>00218 <span class="keywordflow">if</span> (coll-><a class="code" href="struct_o_c_i___coll.html#868c64c81b8bf3ca88c7ca8a6e57af03">typinf</a>-><a class="code" href="struct_o_c_i___type_info.html#f4ec233ab34b64cf0b13abdb97dd8bae">ccode</a> == OCI_TYPECODE_TABLE)<a name="l00219"></a>00219 type = OCI_COLL_NESTED_TABLE;<a name="l00220"></a>00220 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(coll-><a class="code" href="struct_o_c_i___coll.html#868c64c81b8bf3ca88c7ca8a6e57af03">typinf</a>-><a class="code" href="struct_o_c_i___type_info.html#f4ec233ab34b64cf0b13abdb97dd8bae">ccode</a> == OCI_TYPECODE_VARRAY)<a name="l00221"></a>00221 type = OCI_COLL_VARRAY;<a name="l00222"></a>00222 <a name="l00223"></a>00223 OCI_RESULT(TRUE);<a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="keywordflow">return</span> type;<a name="l00226"></a>00226 }<a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00229"></a>00229 <span class="comment"> * OCI_CollGetCount</span><a name="l00230"></a>00230 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00231"></a>00231 <a name="l00232"></a><a class="code" href="group__g__collection.html#gfdc86421c73ed6955a965097cb335a64">00232</a> <span class="keywordtype">int</span> OCI_API <a class="code" href="group__g__collection.html#gfdc86421c73ed6955a965097cb335a64" title="Returns the maximum number of elements of the given collection.">OCI_CollGetMax</a>(<a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll)<a name="l00233"></a>00233 {<a name="l00234"></a>00234 <span class="keywordtype">int</span> max = 0;<a name="l00235"></a>00235 <a name="l00236"></a>00236 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll, 0);<a name="l00237"></a>00237 <a name="l00238"></a>00238 max = OCICollMax(OCILib.env, coll-><a class="code" href="struct_o_c_i___coll.html#cd0eeebc9c44bcabe4a2ef626d94bef1">handle</a>);<a name="l00239"></a>00239 <a name="l00240"></a>00240 OCI_RESULT(TRUE);<a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="keywordflow">return</span> max;<a name="l00243"></a>00243 }<a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00246"></a>00246 <span class="comment"> * OCI_CollGetSize</span><a name="l00247"></a>00247 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00248"></a>00248 <a name="l00249"></a><a class="code" href="group__g__collection.html#g107e9fef3fc0bced6503e566a67dfcb5">00249</a> <span class="keywordtype">int</span> OCI_API <a class="code" href="group__g__collection.html#g107e9fef3fc0bced6503e566a67dfcb5" title="Returns the current number of elements of the given collection.">OCI_CollGetSize</a>(<a class="code" href="struct_o_c_i___coll.html" title="Oracle Collections (VARRAYs and Nested Tables) representation.">OCI_Coll</a> *coll)<a name="l00250"></a>00250 {<a name="l00251"></a>00251 <span class="keywordtype">int</span> size = 0;<a name="l00252"></a>00252 <a name="l00253"></a>00253 OCI_CHECK_PTR(OCI_IPC_COLLECTION, coll, 0);<a name="l00254"></a>00254 <a name="l00255"></a>00255 size = coll-><a class="code" href="struct_o_c_i___coll.html#6d9fad8c88861770d8d825492fffaa5f">size</a>;<a name="l00256"></a>00256 <a name="l00257"></a>00257 OCI_RESULT(TRUE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -