<?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 => 'tr',
  ),
  'this' => 
  array (
    0 => 'function.oci-error.php',
    1 => 'oci_error',
    2 => 'Returns the last error found',
  ),
  'up' => 
  array (
    0 => 'ref.oci8.php',
    1 => 'OCI8 İşlevleri',
  ),
  'prev' => 
  array (
    0 => 'function.oci-define-by-name.php',
    1 => 'oci_define_by_name',
  ),
  'next' => 
  array (
    0 => 'function.oci-execute.php',
    1 => 'oci_execute',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oci8/functions/oci-error.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.oci-error" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">oci_error</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8, PECL OCI8 &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">oci_error</span> &mdash; <span class="dc-title">Returns the last error found</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.oci-error-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>oci_error</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></span> <code class="parameter">$connection_or_statement</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Returns the last error found.
  </p>
  <p class="para">
   The function should be called immediately after an error occurs.
   Errors are cleared by a successful statement.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.oci-error-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection_or_statement</code></dt>
     <dd>
      <p class="para">
       For most errors, <code class="parameter">connection_or_statement</code> is the
       resource handle that was passed to the failing function call.
       For connection errors with <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span>,
       <span class="function"><a href="function.oci-new-connect.php" class="function">oci_new_connect()</a></span> or 
       <span class="function"><a href="function.oci-pconnect.php" class="function">oci_pconnect()</a></span> <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> should be passed.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.oci-error-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="para">
   If no error is found, <span class="function"><strong>oci_error()</strong></span> returns
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. Otherwise, <span class="function"><strong>oci_error()</strong></span> returns the
   error information as an associative array.
  </p>
  <p class="para">
   <table class="doctable table">
   <caption><strong><span class="function"><strong>oci_error()</strong></span> Array Description</strong></caption>

    
     <thead>
      <tr>
       <th>Array key</th>
       <th>Type</th>
       <th>Açıklama</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><code class="literal">code</code></td>
       <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
       <td>
         The Oracle error number.
       </td>
      </tr>

      <tr>
       <td><code class="literal">message</code></td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
         The Oracle error text.
       </td>
      </tr>

      <tr>
       <td><code class="literal">offset</code></td>
       <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
       <td>
         The byte position of an error in the SQL statement.  If there
         was no statement, this is <code class="literal">0</code>
       </td>
      </tr>

      <tr>
       <td><code class="literal">sqltext</code></td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
         The SQL statement text.  If there was no statement, this is
         an empty string.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.oci-error-changelog">
  <h3 class="title">Sürüm Bilgisi</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Sürüm: </th>
      <th>Açıklama</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0, PECL OCI8 3.0.0</td>
      <td>
       <code class="parameter">connection_or_statement</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.oci-error-examples">
  <h3 class="title">Örnekler</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Örnek 1 Displaying the Oracle error message after a connection error</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$conn </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 />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();   </span><span style="color: #FF8000">// For oci_connect errors do not pass a handle<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
   <p class="para">
   <div class="example" id="example-2">
    <p><strong>Örnek 2 Displaying the Oracle error message after a parsing error</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"select ' from dual"</span><span style="color: #007700">);  </span><span style="color: #FF8000">// note mismatched quote<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">$stid</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);  </span><span style="color: #FF8000">// For oci_parse errors pass the connection handle<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Örnek 3 Displaying the Oracle error message, the problematic statement,
     and the position of the problem of an execution error</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"select does_not_exist from dual"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$r</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);  </span><span style="color: #FF8000">// For oci_execute errors pass the statement handle<br />    </span><span style="color: #007700">print </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]);<br />    print </span><span style="color: #DD0000">"\n&lt;pre&gt;\n"</span><span style="color: #007700">;<br />    print </span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'sqltext'</span><span style="color: #007700">]);<br />    </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n%"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'offset'</span><span style="color: #007700">]+</span><span style="color: #0000BB">1</span><span style="color: #007700">).</span><span style="color: #DD0000">"s"</span><span style="color: #007700">, </span><span style="color: #DD0000">"^"</span><span style="color: #007700">);<br />    print  </span><span style="color: #DD0000">"\n&lt;/pre&gt;\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

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