<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.oci8.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.oci-set-db-operation.php',
    1 => 'oci_set_db_operation',
    2 => 'Sets the database operation',
  ),
  'up' => 
  array (
    0 => 'ref.oci8.php',
    1 => 'OCI8 Functions',
  ),
  'prev' => 
  array (
    0 => 'function.oci-set-client-info.php',
    1 => 'oci_set_client_info',
  ),
  'next' => 
  array (
    0 => 'function.oci-set-edition.php',
    1 => 'oci_set_edition',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oci8/functions/oci-set-db-operation.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.oci-set-db-operation" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">oci_set_db_operation</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.14, PHP 8, PHP 7 &gt;= 7.3.1, PHP 8, PECL OCI8 &gt;= 2.2.0)</p><p class="refpurpose"><span class="refname">oci_set_db_operation</span> &mdash; <span class="dc-title">Sets the database operation</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.oci-set-db-operation-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>oci_set_db_operation</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$connection</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$action</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
    Sets the DBOP for Oracle tracing.
  </p>
  <p class="para">
   The database operation name is registered with the database when the next
   &#039;round-trip&#039; from PHP to the database occurs, typically when a SQL
   statement is executed.
  </p>
  <p class="para">
   The database operation can subsequently be queried from database administration
   views such as <code class="literal">V$SQL_MONITOR</code>.
  </p>
  <p class="para">
   The <span class="function"><strong>oci_set_db_operation()</strong></span> function is available
   when OCI8 uses Oracle 12 (or later) Client libraries and Oracle Database 12 (or later).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.oci-set-db-operation-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
       <p class="para">An Oracle connection identifier,
returned by <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span>, <span class="function"><a href="function.oci-pconnect.php" class="function">oci_pconnect()</a></span>,
or <span class="function"><a href="function.oci-new-connect.php" class="function">oci_new_connect()</a></span>.</p>
     </dd>
    
    
     <dt><code class="parameter">action</code></dt>
     <dd>
      <p class="para">
       User chosen string.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.oci-set-db-operation-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.oci-set-db-operation-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Setting the DBOP</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$c </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">, </span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Record the operation<br /></span><span style="color: #0000BB">oci_set_db_operation</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">, </span><span style="color: #DD0000">'main query'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Code that causes a round-trip, for example a query:<br /></span><span style="color: #0000BB">$s </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">, </span><span style="color: #DD0000">'select * from dual'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_fetch_all</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">, </span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">sleep</span><span style="color: #007700">(</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">// While the script is running, the administrator can see the database operations
// being performed:

sqlplus system/welcome
SQL&gt; select dbop_name from v$sql_monitor;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.oci-set-db-operation-notes">
  <h3 class="title">Notes</h3>
  <div class="caution"><strong class="caution">Caution</strong><h1 class="title">Round-trip Gotcha</h1>
<p class="para">Some but not all OCI8 functions cause round-trips.  Round-trips to the
database may not occur with queries when result caching is enabled.
</p></div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.oci-set-db-operation-seealso">
   <h3 class="title">See Also</h3>
   <p class="para">
     <ul class="simplelist">
       <li><span class="function"><a href="function.oci-set-action.php" class="function" rel="rdfs-seeAlso">oci_set_action()</a> - Sets the action name</span></li>
       <li><span class="function"><a href="function.oci-set-module-name.php" class="function" rel="rdfs-seeAlso">oci_set_module_name()</a> - Sets the module name</span></li>
       <li><span class="function"><a href="function.oci-set-client-info.php" class="function" rel="rdfs-seeAlso">oci_set_client_info()</a> - Sets the client information</span></li>
       <li><span class="function"><a href="function.oci-set-client-identifier.php" class="function" rel="rdfs-seeAlso">oci_set_client_identifier()</a> - Sets the client identifier</span></li>
     </ul>
   </p>
 </div>


</div><?php manual_footer($setup); ?>