<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
  <refentry id="function.oci-define-by-name">
   <refnamediv>
    <refname>oci_define_by_name</refname>
    <refpurpose>
     Uses a PHP variable for the define-step during a SELECT
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>oci_define_by_name</methodname>
      <methodparam><type>resource</type><parameter>statement</parameter></methodparam>
      <methodparam><type>string</type><parameter>column_name</parameter></methodparam>
      <methodparam><type>mixed</type><parameter role="reference">variable</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>oci_define_by_name</function> defines PHP variables for fetches
     of SQL-Columns. Be careful that Oracle uses ALL-UPPERCASE column names,
     whereby in your select you can also write lowercase.
     <function>oci_define_by_name</function> expects
     the <parameter>column_name</parameter> to be in uppercase. If you
     define a variable that doesn't exists in your select statement, no
     error will issued.
    </para>   
    <para>
     If you need to define an abstract datatype (LOB/ROWID/BFILE) you
     must allocate it first using
     <function>oci_new_descriptor</function>. See also the
     <function>oci_bind_by_name</function> function.
    </para>
     <example>
      <title><function>oci_define_by_name</function> example</title>
      <programlisting role="php">
<![CDATA[
<?php
/* oci_define_by_name example - thies at thieso dot net (980219) */

$conn = oci_connect("scott", "tiger");

$stmt = oci_parse($conn, "SELECT empno, ename FROM emp");

/* the define MUST be done BEFORE oci_execute! */

oci_define_by_name($stmt, "EMPNO", $empno);
oci_define_by_name($stmt, "ENAME", $ename);

oci_execute($stmt);

while (oci_fetch($stmt)) {
    echo "empno:" . $empno . "\n";
    echo "ename:" . $ename . "\n";
}

oci_free_statement($stmt);
oci_close($conn);
?>
]]>
     </programlisting>
    </example>
    <note>
     <para>
      In PHP versions before 5.0.0 you must use <function>ocidefinebyname</function> instead. 
      This name still can be used, it was left as alias of
      <function>oci_define_by_name</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
-->