xref: /PHP-8.3/ext/oci8/tests/array_bind_002.phpt (revision a53e5617)
1--TEST--
2oci_bind_array_by_name() and invalid values 2
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_002_PKG AS
24  TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
25  PROCEDURE iobind(c1 IN OUT ARRTYPE);
26END ARRAY_BIND_002_PKG;";
27$statement = oci_parse($c, $create_pkg);
28oci_execute($statement);
29
30$create_pkg_body = "
31CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_002_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_002_PKG;";
50$statement = oci_parse($c, $create_pkg_body);
51oci_execute($statement);
52
53$statement = oci_parse($c, "BEGIN array_bind_002_pkg.iobind(:c1); END;");
54
55$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
56
57try {
58    oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT);
59} catch (ValueError $e) {
60    echo $e->getMessage(), "\n";
61}
62
63oci_execute($statement);
64
65var_dump($array);
66
67echo "Done\n";
68?>
69--EXPECTF--
70oci_bind_array_by_name(): Argument #4 ($max_array_length) must be greater than 0
71
72Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
73array(5) {
74  [0]=>
75  string(9) "06-DEC-05"
76  [1]=>
77  string(9) "10-DEC-80"
78  [2]=>
79  string(9) "21-AUG-91"
80  [3]=>
81  string(9) "26-OCT-17"
82  [4]=>
83  string(9) "05-NOV-05"
84}
85Done
86