1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 297028 $ -->
<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 PHP array to Oracle PL/SQL array by name</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 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 use find the longest
element in the incoming array and will use it as maximum length for
array items.
</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
$c = oci_connect("scott", "tiger");
$create = "CREATE TABLE bind_example(name VARCHAR(20))";
$statement = oci_parse($c, $create);
oci_execute($statement);
$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;";
$statement = oci_parse($c, $create_pkg);
oci_execute($statement);
$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
FOR i IN 1..5 LOOP
INSERT INTO bind_example VALUES (c1(i));
END LOOP;
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;";
$statement = oci_parse($c, $create_pkg_body);
oci_execute($statement);
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
$array = array("one", "two", "three", "four", "five");
oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR);
oci_execute($statement);
var_dump($array);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
This function is available since OCI8 release 1.2.
</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:"~/.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
-->
|