php-doc-en/reference/oci8/functions/oci-error.xml
Antony Dovgal b2da15136d updated OCI8 docs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@195287 c90b9560-bf6c-de11-be94-00142212c4b1
2005-09-06 20:18:30 +00:00

109 lines
3.3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<refentry id="function.oci-error">
<refnamediv>
<refname>oci_error</refname>
<refpurpose>Returns the last error found</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>oci_error</methodname>
<methodparam choice="opt"><type>resource</type><parameter>source</parameter></methodparam>
</methodsynopsis>
<para>
For most errors, the parameter is the most appropriate resource
handle. For connection errors with <function>oci_connect</function>,
<function>oci_new_connect</function> or <function>oci_pconnect</function>,
do not pass a parameter. If no error is found, <function>oci_error</function>
returns &false;. <function>oci_error</function> returns the error as an
associative array. In this array, <literal>code</literal>
consists the oracle error code and <literal>message</literal>
the oracle error string.
</para>
<note>
<title>As of PHP 4.3</title>
<para>
<literal>offset</literal> and <literal>sqltext</literal> will
also be included in the return array to indicate the location
of the error and the original SQL text which caused it.
</para>
</note>
<para>
<example>
<title>Displaying the Oracle error message after a connection error</title>
<programlisting role="php">
<![CDATA[
$conn = @oci_connect("scott", "tiger", "mydb");
if (!$conn) {
$e = oci_error(); // For oci_connect errors pass no handle
echo htmlentities($e['message']);
}
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Displaying the Oracle error message after a parsing error</title>
<programlisting role="php">
<![CDATA[
$stmt = @oci_parse($conn, "select ' from dual"); // note mismatched quote
if (!$stmt) {
$e = oci_error($conn); // For oci_parse errors pass the connection handle
echo htmlentities($e['message']);
}
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Displaying the Oracle error message and problematic statement
after an execution error</title>
<programlisting role="php">
<![CDATA[
$r = oci_execute($stmt);
if (!$r) {
$e = oci_error($stmt); // For oci_execute errors pass the statementhandle
echo htmlentities($e['message']);
echo "<pre>";
echo htmlentities($e['sqltext']);
printf("\n%".($e['offset']+1)."s", "^");
echo "</pre>";
}
]]>
</programlisting>
</example>
</para>
<note>
<para>
In PHP versions before 5.0.0 you must use <function>ocierror</function> instead.
This name still can be used, it was left as alias of
<function>oci_error</function> for downwards compatability.
This, however, is deprecated and not recommended.
</para>
</note>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->