PHP Manual
Prev |  | Next

# OCIDefineByName

OCIDefineByName -- Use a PHP variable for the define-step during a SELECT

## Description

`int OCIDefineByName`(int stmt, string Column-Name, mixed &variable, int [type]);

OCIDefineByName() uses fetches SQL-Columns into user-defined PHP-Variables. Be careful that Oracle user ALL-UPPERCASE column-names, whereby in your select you can also write lower-case. OCIDefineByName() expects the `Column-Name` to be in uppercase. If you define a variable that doesn't exists in you select statement, no error will be given!

If you need to define an abstract Datatype (LOB/ROWID/BFILE) you need to allocate it first using OCINewDescriptor() function. See also the OCIBindByName() function.

Example 1. OCIDefineByName

      1
      2 <?php
      3 /* OCIDefineByPos example thies@digicol.de (980219) */
      4
      5 $conn = OCILogon("scott","tiger");
      6
      7 $stmt = OCIParse($conn,"select empno, ename from emp");
      8
      9 /* the define MUST be done BEFORE ociexecute! */
     10
     11 OCIDefineByName($stmt,"EMPNO",&$empno);
     12 OCIDefineByName($stmt,"ENAME",&$ename);
     13
     14 OCIExecute($stmt);
     15
     16 while (OCIFetch($stmt)) {
     17     echo "empno:".$empno."\n";
     18     echo "ename:".$ename."\n";
     19 }
     20
     21 OCIFreeStatement($stmt);
     22 OCILogoff($conn);
     23 ?>

Prev | Home | Next
Oracle 8 functions | Up | OCIBindByName