⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection_8c-source.html

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00138"></a>00138         res = FALSE;<a name="l00139"></a>00139 <a name="l00140"></a>00140    <span class="comment">/* update internal status */</span><a name="l00141"></a>00141     <a name="l00142"></a>00142     <span class="keywordflow">if</span> (res == TRUE)<a name="l00143"></a>00143     {<a name="l00144"></a>00144         con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> = OCI_CONN_ALLOCATED;<a name="l00145"></a>00145     }<a name="l00146"></a>00146     <span class="keywordflow">else</span><a name="l00147"></a>00147     {<a name="l00148"></a>00148         <a class="code" href="group__g__connect.html#gc3fe655e96074adb119908be4650a4c9" title="Close a physical connection to an Oracle database server.">OCI_ConnectionFree</a>(con);<a name="l00149"></a>00149         con = NULL;<a name="l00150"></a>00150     }<a name="l00151"></a>00151 <a name="l00152"></a>00152     <span class="keywordflow">return</span> con;<a name="l00153"></a>00153 }<a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00156"></a>00156 <span class="comment"> * OCI_ConnectionDeallocate</span><a name="l00157"></a>00157 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordtype">boolean</span> OCI_ConnectionDeallocate(<a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *con)<a name="l00160"></a>00160 {<a name="l00161"></a>00161     OCI_CHECK(con == NULL, FALSE);<a name="l00162"></a>00162     OCI_CHECK(con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> != OCI_CONN_ALLOCATED, FALSE);<a name="l00163"></a>00163 <a name="l00164"></a>00164     <span class="comment">/* close context handle */</span><a name="l00165"></a>00165     <a name="l00166"></a>00166     <span class="keywordflow">if</span> (con-&gt;<a class="code" href="struct_o_c_i___connection.html#f20d1bea40e79481aeece933a4c70898">cxt</a> != NULL)<a name="l00167"></a>00167        OCI_HandleFree((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#f20d1bea40e79481aeece933a4c70898">cxt</a>, (ub4) OCI_HTYPE_SVCCTX);<a name="l00168"></a>00168 <a name="l00169"></a>00169     <span class="comment">/* close session handle */</span><a name="l00170"></a>00170     <a name="l00171"></a>00171     <span class="keywordflow">if</span> (con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a> != NULL)<a name="l00172"></a>00172         OCI_HandleFree((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a>, (ub4) OCI_HTYPE_SESSION);<a name="l00173"></a>00173 <a name="l00174"></a>00174     <span class="comment">/* close server handle */</span><a name="l00175"></a>00175     <span class="keywordflow">if</span> (con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a> != NULL)<a name="l00176"></a>00176         OCI_HandleFree((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a>, (ub4) OCI_HTYPE_SERVER);<a name="l00177"></a>00177 <a name="l00178"></a>00178      <span class="comment">/* close error handle */</span><a name="l00179"></a>00179     <a name="l00180"></a>00180     <span class="keywordflow">if</span> (con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a> != NULL)<a name="l00181"></a>00181         OCI_HandleFree((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, (ub4) OCI_HTYPE_ERROR);<a name="l00182"></a>00182 <a name="l00183"></a>00183     con-&gt;<a class="code" href="struct_o_c_i___connection.html#f20d1bea40e79481aeece933a4c70898">cxt</a> = NULL;<a name="l00184"></a>00184     con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a> = NULL;<a name="l00185"></a>00185     con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a> = NULL;<a name="l00186"></a>00186     con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a> = NULL;<a name="l00187"></a>00187 <a name="l00188"></a>00188     <span class="keywordflow">return</span> TRUE;<a name="l00189"></a>00189 }<a name="l00190"></a>00190 <a name="l00191"></a>00191 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00192"></a>00192 <span class="comment"> * OCI_ConnectionAttach</span><a name="l00193"></a>00193 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="keywordtype">boolean</span> OCI_ConnectionAttach(<a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *con)<a name="l00196"></a>00196 {<a name="l00197"></a>00197     <span class="keywordtype">void</span> *ostr  = NULL;<a name="l00198"></a>00198     <span class="keywordtype">int</span> osize   = -1;<a name="l00199"></a>00199     <span class="keywordtype">boolean</span> res = TRUE;<a name="l00200"></a>00200     ub4 cmode   = OCI_DEFAULT;<a name="l00201"></a>00201 <a name="l00202"></a>00202     OCI_CHECK(con == NULL, FALSE);<a name="l00203"></a>00203     OCI_CHECK(con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> != OCI_CONN_ALLOCATED, FALSE);<a name="l00204"></a>00204 <a name="l00205"></a>00205     <span class="comment">/* attach server handle to service name */</span><a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="preprocessor">#if OCI_VERSION_COMPILE &gt;= OCI_9</span><a name="l00208"></a>00208 <span class="preprocessor"></span><a name="l00209"></a>00209     <span class="keywordflow">if</span> (OCILib.ver_runtime &gt;= OCI_9 &amp;&amp; con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a> != NULL)<a name="l00210"></a>00210     {<a name="l00211"></a>00211         ostr  = OCI_GetInputMetaString(con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a>-&gt;<a class="code" href="struct_o_c_i___conn_pool.html#bae2a49d41482b4ed064b0ecf839ea42">name</a>, &amp;osize);<a name="l00212"></a>00212         cmode = OCI_CPOOL;<a name="l00213"></a>00213     }<a name="l00214"></a>00214     <span class="keywordflow">else</span><a name="l00215"></a>00215 <a name="l00216"></a>00216 <span class="preprocessor">#endif</span><a name="l00217"></a>00217 <span class="preprocessor"></span><a name="l00218"></a>00218     {<a name="l00219"></a>00219         ostr  = OCI_GetInputMetaString(con-&gt;<a class="code" href="struct_o_c_i___connection.html#c8336afdd35c8b68b4d04c7881a22fa2">db</a>, &amp;osize);<a name="l00220"></a>00220     }<a name="l00221"></a>00221 <a name="l00222"></a>00222     OCI_CALL2<a name="l00223"></a>00223     (<a name="l00224"></a>00224         res, con, <a name="l00225"></a>00225         <a name="l00226"></a>00226         OCIServerAttach(con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a>, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>,(OraText *) ostr, (sb4) osize, cmode)<a name="l00227"></a>00227     )<a name="l00228"></a>00228     <a name="l00229"></a>00229     OCI_ReleaseMetaString(ostr);<a name="l00230"></a>00230 <a name="l00231"></a>00231     <span class="comment">/* handle errors */</span><a name="l00232"></a>00232     <a name="l00233"></a>00233     if (res == TRUE)<a name="l00234"></a>00234     {<a name="l00235"></a>00235         <span class="keywordflow">if</span> (OCILib.ver_runtime &lt; OCI_9 &amp;&amp; con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a> != NULL)<a name="l00236"></a>00236             con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a>-&gt;<a class="code" href="struct_o_c_i___conn_pool.html#156dc09d514ccbbb775f4582445a6126">nb_opened</a>++;<a name="l00237"></a>00237 <a name="l00238"></a>00238         con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> = OCI_CONN_ATTACHED;<a name="l00239"></a>00239     }<a name="l00240"></a>00240 <a name="l00241"></a>00241     <span class="keywordflow">return</span> res;<a name="l00242"></a>00242 }<a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00245"></a>00245 <span class="comment"> * OCI_ConnectionDetach</span><a name="l00246"></a>00246 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00247"></a>00247 <a name="l00248"></a>00248 <span class="keywordtype">boolean</span> OCI_ConnectionDetach(<a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *con)<a name="l00249"></a>00249 {<a name="l00250"></a>00250     <span class="keywordtype">boolean</span> res = TRUE;<a name="l00251"></a>00251 <a name="l00252"></a>00252     OCI_CHECK(con == NULL, FALSE);<a name="l00253"></a>00253     OCI_CHECK(con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> != OCI_CONN_ATTACHED, FALSE);<a name="l00254"></a>00254 <a name="l00255"></a>00255     <span class="comment">/* detach from the oracle server */</span><a name="l00256"></a>00256     <a name="l00257"></a>00257     OCI_CALL2<a name="l00258"></a>00258     (<a name="l00259"></a>00259         res, con, <a name="l00260"></a>00260         <a name="l00261"></a>00261         OCIServerDetach(con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a>, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, (ub4) OCI_DEFAULT)<a name="l00262"></a>00262     )<a name="l00263"></a>00263  <a name="l00264"></a>00264    <span class="comment">/* update internal status */</span><a name="l00265"></a>00265 <a name="l00266"></a>00266     <span class="keywordflow">if</span> (res == TRUE)<a name="l00267"></a>00267     {<a name="l00268"></a>00268         <span class="keywordflow">if</span> (OCILib.ver_runtime &lt; OCI_9 &amp;&amp; con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a> != NULL)<a name="l00269"></a>00269             con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a>-&gt;<a class="code" href="struct_o_c_i___conn_pool.html#156dc09d514ccbbb775f4582445a6126">nb_opened</a>--;<a name="l00270"></a>00270 <a name="l00271"></a>00271         con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> = OCI_CONN_ALLOCATED;<a name="l00272"></a>00272     }<a name="l00273"></a>00273 <a name="l00274"></a>00274     <span class="keywordflow">return</span> res;<a name="l00275"></a>00275 }<a name="l00276"></a>00276 <a name="l00277"></a>00277 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00278"></a>00278 <span class="comment"> * OCI_ConnectionLogon</span><a name="l00279"></a>00279 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="keywordtype">boolean</span> OCI_ConnectionLogon(<a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *con)<a name="l00282"></a>00282 {<a name="l00283"></a>00283     <span class="keywordtype">void</span> *ostr  = NULL;<a name="l00284"></a>00284     <span class="keywordtype">int</span> osize   = -1;<a name="l00285"></a>00285     <span class="keywordtype">boolean</span> res = TRUE;<a name="l00286"></a>00286     <a name="l00287"></a>00287     OCI_CHECK(con == NULL, FALSE);<a name="l00288"></a>00288 <a name="l00289"></a>00289     <span class="comment">/* set context server attribute */</span>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -