<HTML ><HEAD ><TITLE >Oracle 8 functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="deaggregate" HREF="function.deaggregate.html"><LINK REL="NEXT" TITLE="OCIBindByName" HREF="function.ocibindbyname.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.deaggregate.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ocibindbyname.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.oci8" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >LXXI. Oracle 8 functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN66439" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.intro" ></A >Introduction</H1 ><P > These functions allow you to access Oracle8 and Oracle7 databases. It uses the Oracle8 Call-Interface (OCI8) </P ><P > This extension is more flexible than the <A HREF="ref.oracle.html" >standard Oracle</A > extension. It supports binding of global and local PHP variables to Oracle placeholders, has full LOB, FILE and ROWID support and allows you to use user-supplied define variables. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.requirements" ></A >Requirements</H1 ><P > You will need the Oracle8 client libraries to use this extension. </P ><P > Before using this extension, make sure that you have set up your Oracle environment variables properly for the Oracle user, as well as your web daemon user. The variables you might need to set are as follows: <P ></P ><UL ><LI ><P > ORACLE_HOME </P ></LI ><LI ><P > ORACLE_SID </P ></LI ><LI ><P > LD_PRELOAD </P ></LI ><LI ><P > LD_LIBRARY_PATH </P ></LI ><LI ><P > NLS_LANG </P ></LI ><LI ><P > ORA_NLS33 </P ></LI ></UL > </P ><P > After setting up the environment variables for your webserver user, be sure to also add the webserver user (nobody, www) to the oracle group. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >If your webserver doesn't start or crashes at startup: </B > Check that Apache is linked with the pthread library: </P ><P > <DIV CLASS="informalexample" ><A NAME="AEN66467" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" ># ldd /www/apache/bin/httpd libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000) libm.so.6 => /lib/libm.so.6 (0x4002f000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x4004c000) libdl.so.2 => /lib/libdl.so.2 (0x4007a000) libc.so.6 => /lib/libc.so.6 (0x4007e000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)</PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > If the libpthread is not listed you have to reinstall Apache: </P ><P > <DIV CLASS="informalexample" ><A NAME="AEN66471" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" ># cd /usr/src/apache_1.3.xx # make clean # LIBS=-lpthread ./config.status # make # make install</PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > Please note that on some systems like UnixWare it is libthread instead of libpthread. PHP and Apache have to be configured with EXTRA_LIBS=-lthread. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.installation" ></A >Installation</H1 ><P > You have to compile PHP with the option <TT CLASS="option" >--with-oci8[=DIR]</TT >, where DIR defaults to your environmment variable ORACLE_HOME. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.resources" ></A >Resource Types</H1 ><P > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.constants" ></A >Predefined Constants</H1 ><P > The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >OCI_DEFAULT</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_DESCRIBE_ONLY</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_COMMIT_ON_SUCCESS</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_EXACT_FETCH</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >SQLT_BFILEE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >SQLT_CFILEE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >SQLT_CLOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >SQLT_BLOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >SQLT_RDD</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_SQLT_NTY</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_SYSDATE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_BFILE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_CFILEE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_CLOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_BLOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_ROWID</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_CURSOR</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_B_BIN</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_FETCHSTATEMENT_BY_COLUMN</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_FETCHSTATEMENT_BY_ROW</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_ASSOC</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_NUM</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_BOTH</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_RETURN_NULLS</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_RETURN_LOBS</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_DTYPE_FILE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_DTYPE_LOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_DTYPE_ROWID</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_D_FILE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_D_LOB</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >OCI_D_ROWID</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="oci8.examples" ></A >Examples</H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN66678" ></A ><P ><B >Example 1. OCI Hints</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // by sergo@bacup.ru // Use option: OCI_DEFAULT for execute command to delay execution OCIExecute($stmt, OCI_DEFAULT); // for retrieve data use (after fetch): $result = OCIResult($stmt, $n); if (is_object ($result)) $result = $result->load(); // For INSERT or UPDATE statement use: $sql = "insert into table (field1, field2) values (field1 = 'value', field2 = empty_clob()) returning field2 into :field2"; OCIParse($conn, $sql); $clob = OCINewDescriptor($conn, OCI_D_LOB); OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); OCIExecute($stmt, OCI_DEFAULT); $clob->save ("some text"); OCICommit($conn); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > You can easily access stored procedures in the same way as you would from the commands line. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN66682" ></A ><P ><B >Example 2. Using Stored Procedures</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // by webmaster@remoterealty.com $sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname', '$lastname', '$company', '$address1', '$address2', '$city', '$state', '$postalcode', '$country', :error_code );end;" ); // This calls stored procedure sp_newaddress, with :address_id being an // in/out variable and :error_code being an out variable. // Then you do the binding: OCIBindByName ( $sth, ":address_id", $addr_id, 10 ); OCIBindByName ( $sth, ":error_code", $errorcode, 10 ); OCIExecute ( $sth ); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.ocibindbyname.html" >OCIBindByName</A > -- Bind a PHP variable to an Oracle Placeholder </DT ><DT ><A HREF="function.ocicancel.html" >OCICancel</A > -- Cancel reading from cursor</DT ><DT ><A HREF="function.ocicollappend.html" >OCICollAppend</A > -- Coming soon</DT ><DT ><A HREF="function.ocicollassign.html" >OCICollAssign</A > -- Coming soon</DT ><DT ><A HREF="function.ocicollassignelem.html" >OCICollAssignElem</A > -- Coming soon</DT ><DT ><A HREF="function.ocicollgetelem.html" >OCICollGetElem</A > -- Coming soon</DT ><DT ><A HREF="function.ocicollmax.html" >OCICollMax</A > -- Coming soon</DT ><DT ><A HREF="function.ocicollsize.html" >OCICollSize</A > -- Coming soon</DT ><DT ><A HREF="function.ocicolltrim.html" >OCICollTrim</A > -- Coming soon</DT ><DT ><A HREF="function.ocicolumnisnull.html" >OCIColumnIsNULL</A > -- Test whether a result column is <TT CLASS="constant" ><B >NULL</B ></TT ></DT ><DT ><A HREF="function.ocicolumnname.html" >OCIColumnName</A > -- Returns the name of a column</DT ><DT ><A HREF="function.ocicolumnprecision.html" >OCIColumnPrecision</A > -- Coming soon</DT ><DT ><A HREF="function.ocicolumnscale.html" >OCIColumnScale</A > -- Coming soon</DT ><DT ><A HREF="function.ocicolumnsize.html" >OCIColumnSize</A > -- Return result column size</DT ><DT ><A HREF="function.ocicolumntype.html" >OCIColumnType</A > -- Returns the data type of a column</DT ><DT ><A HREF="function.ocicolumntyperaw.html" >OCIColumnTypeRaw</A > -- Coming soon</DT ><DT ><A HREF="function.ocicommit.html" >OCICommit</A > -- Commits outstanding transactions</DT ><DT ><A HREF="function.ocidefinebyname.html" >OCIDefineByName</A > -- Use a PHP variable for the define-step during a SELECT </DT ><DT ><A HREF="function.ocierror.html" >OCIError</A > -- Return the last error of stmt|conn|global </DT ><DT ><A HREF="function.ociexecute.html" >OCIExecute</A > -- Execute a statement</DT ><DT ><A HREF="function.ocifetch.html" >OCIFetch</A > -- Fetches the next row into result-buffer</DT ><DT ><A HREF="function.ocifetchinto.html" >OCIFetchInto</A > -- Fetches the next row into result-array</DT ><DT ><A HREF="function.ocifetchstatement.html" >OCIFetchStatement</A > -- Fetch all rows of result data into an array</DT ><DT ><A HREF="function.ocifreecollection.html" >OCIFreeCollection</A > -- Coming soon</DT ><DT ><A HREF="function.ocifreecursor.html" >OCIFreeCursor</A > -- Free all resources associated with a cursor </DT ><DT ><A HREF="function.ocifreedesc.html" >OCIFreeDesc</A > -- Deletes a large object descriptor</DT ><DT ><A HREF="function.ocifreestatement.html" >OCIFreeStatement</A > -- Free all resources associated with a statement </DT ><DT ><A HREF="function.ociinternaldebug.html" >OCIInternalDebug</A > -- Enables or disables internal debug output </DT ><DT ><A HREF="function.ociloadlob.html" >OCILoadLob</A > -- Coming soon</DT ><DT ><A HREF="function.ocilogoff.html" >OCILogOff</A > -- Disconnects from Oracle</DT ><DT ><A HREF="function.ocilogon.html" >OCILogon</A > -- Establishes a connection to Oracle</DT ><DT ><A HREF="function.ocinewcollection.html" >OCINewCollection</A > -- Coming soon</DT ><DT ><A HREF="function.ocinewcursor.html" >OCINewCursor</A > -- Return a new cursor (Statement-Handle) </DT ><DT ><A HREF="function.ocinewdescriptor.html" >OCINewDescriptor</A > -- Initialize a new empty LOB or FILE descriptor </DT ><DT ><A HREF="function.ocinlogon.html" >OCINLogon</A > -- Establishes a new connection to Oracle</DT ><DT ><A HREF="function.ocinumcols.html" >OCINumCols</A > -- Return the number of result columns in a statement </DT ><DT ><A HREF="function.ociparse.html" >OCIParse</A > -- Parse a query and return a statement</DT ><DT ><A HREF="function.ociplogon.html" >OCIPLogon</A > -- Connect to an Oracle database using a persistent connection</DT ><DT ><A HREF="function.ociresult.html" >OCIResult</A > -- Returns column value for fetched row</DT ><DT ><A HREF="function.ocirollback.html" >OCIRollback</A > -- Rolls back outstanding transactions</DT ><DT ><A HREF="function.ocirowcount.html" >OCIRowCount</A > -- Gets the number of affected rows</DT ><DT ><A HREF="function.ocisavelob.html" >OCISaveLob</A > -- Coming soon</DT ><DT ><A HREF="function.ocisavelobfile.html" >OCISaveLobFile</A > -- Coming soon</DT ><DT ><A HREF="function.ociserverversion.html" >OCIServerVersion</A > -- Return a string containing server version information</DT ><DT ><A HREF="function.ocisetprefetch.html" >OCISetPrefetch</A > -- Sets number of rows to be prefetched</DT ><DT ><A HREF="function.ocistatementtype.html" >OCIStatementType</A > -- Return the type of an OCI statement</DT ><DT ><A HREF="function.ociwritelobtofile.html" >OCIWriteLobToFile</A > -- Coming soon</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.deaggregate.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ocibindbyname.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >deaggregate</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >OCIBindByName</TD ></TR ></TABLE ></DIV ></BODY ></HTML >