xref: /PHP-8.3/ext/oci8/tests/array_bind_001.phpt (revision a53e5617)
1--TEST--
2oci_bind_array_by_name() and invalid values 1
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14$drop = "DROP table bind_test";
15$statement = oci_parse($c, $drop);
16@oci_execute($statement);
17
18$create = "CREATE table bind_test(name DATE)";
19$statement = oci_parse($c, $create);
20oci_execute($statement);
21
22$create_pkg = "
23CREATE OR REPLACE PACKAGE ARRAY_BIND_001_PKG AS
24  TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
25  PROCEDURE iobind(c1 IN OUT ARRTYPE);
26END ARRAY_BIND_001_PKG;";
27$statement = oci_parse($c, $create_pkg);
28oci_execute($statement);
29
30$create_pkg_body = "
31CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_001_PKG AS
32  CURSOR CUR IS SELECT name FROM bind_test;
33  PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
34    BEGIN
35    FOR i IN 1..5 LOOP
36      INSERT INTO bind_test VALUES (c1(i));
37    END LOOP;
38    IF NOT CUR%ISOPEN THEN
39      OPEN CUR;
40    END IF;
41    FOR i IN REVERSE 1..5 LOOP
42      FETCH CUR INTO c1(i);
43      IF CUR%NOTFOUND THEN
44        CLOSE CUR;
45        EXIT;
46      END IF;
47    END LOOP;
48  END iobind;
49END ARRAY_BIND_001_PKG;";
50$statement = oci_parse($c, $create_pkg_body);
51oci_execute($statement);
52
53$statement = oci_parse($c, "BEGIN array_bind_001_pkg.iobind(:c1); END;");
54
55$array = "";
56
57oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT);
58
59oci_execute($statement);
60
61var_dump($array);
62
63echo "Done\n";
64?>
65--EXPECTF--
66Warning: oci_bind_array_by_name(): OCI-21560: argument 3 is null, invalid, or out of range in %s on line %d
67
68Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
69array(1) {
70  [0]=>
71  string(0) ""
72}
73Done
74