mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@333046 c90b9560-bf6c-de11-be94-00142212c4b1
239 lines
6.5 KiB
XML
239 lines
6.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.oci-bind-array-by-name" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>oci_bind_array_by_name</refname>
|
|
<refpurpose>Binds a PHP array to an Oracle PL/SQL array parameter</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>oci_bind_array_by_name</methodname>
|
|
<methodparam><type>resource</type><parameter>statement</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter role="reference">var_array</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>max_table_length</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>max_item_length</parameter><initializer>-1</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>type</parameter><initializer>SQLT_AFC</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Binds the PHP array <parameter>var_array</parameter> to the Oracle
|
|
placeholder <parameter>name</parameter>, which points to an Oracle PL/SQL
|
|
array. Whether it will be used for input or output will be determined at
|
|
run-time.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>statement</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A valid OCI statement identifier.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The Oracle placeholder.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>var_array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An array.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>max_table_length</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Sets the maximum length both for incoming and result arrays.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>max_item_length</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Sets maximum length for array items. If not specified or equals to -1,
|
|
<function>oci_bind_array_by_name</function> will find the longest
|
|
element in the incoming array and will use it as the maximum length.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>type</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Should be used to set the type of PL/SQL array items. See list of
|
|
available types below:
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_NUM</constant> - for arrays of NUMBER.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_INT</constant> - for arrays of INTEGER (Note: INTEGER
|
|
it is actually a synonym for NUMBER(38), but
|
|
<constant>SQLT_NUM</constant> type won't work in this case even
|
|
though they are synonyms).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_FLT</constant> - for arrays of FLOAT.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_AFC</constant> - for arrays of CHAR.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_CHR</constant> - for arrays of VARCHAR2.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_VCS</constant> - for arrays of VARCHAR.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_AVC</constant> - for arrays of CHARZ.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_STR</constant> - for arrays of STRING.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_LVC</constant> - for arrays of LONG VARCHAR.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>SQLT_ODT</constant> - for arrays of DATE.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>oci_bind_array_by_name</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = oci_connect("hr", "hrpwd", "localhost/XE");
|
|
if (!$conn) {
|
|
$m = oci_error();
|
|
trigger_error(htmlentities($m['message']), E_USER_ERROR);
|
|
}
|
|
|
|
$create = "CREATE TABLE bind_example(name VARCHAR(20))";
|
|
$stid = oci_parse($conn, $create);
|
|
oci_execute($stid);
|
|
|
|
$create_pkg = "
|
|
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
|
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
|
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
|
END ARRAYBINDPKG1;";
|
|
$stid = oci_parse($conn, $create_pkg);
|
|
oci_execute($stid);
|
|
|
|
$create_pkg_body = "
|
|
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|
CURSOR CUR IS SELECT name FROM bind_example;
|
|
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
|
BEGIN
|
|
-- Bulk Insert
|
|
FORALL i IN INDICES OF c1
|
|
INSERT INTO bind_example VALUES (c1(i));
|
|
|
|
-- Fetch and reverse
|
|
IF NOT CUR%ISOPEN THEN
|
|
OPEN CUR;
|
|
END IF;
|
|
FOR i IN REVERSE 1..5 LOOP
|
|
FETCH CUR INTO c1(i);
|
|
IF CUR%NOTFOUND THEN
|
|
CLOSE CUR;
|
|
EXIT;
|
|
END IF;
|
|
END LOOP;
|
|
END iobind;
|
|
END ARRAYBINDPKG1;";
|
|
$stid = oci_parse($conn, $create_pkg_body);
|
|
oci_execute($stid);
|
|
|
|
$stid = oci_parse($conn, "BEGIN arraybindpkg1.iobind(:c1); END;");
|
|
$array = array("one", "two", "three", "four", "five");
|
|
oci_bind_array_by_name($stid, ":c1", $array, 5, -1, SQLT_CHR);
|
|
oci_execute($stid);
|
|
|
|
var_dump($array);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</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:"~/.phpdoc/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
|
|
-->
|
|
|