xref: /PHP-8.2/ext/oci8/tests/array_bind_003.phpt (revision b5a14e6c)
1--TEST--
2oci_bind_array_by_name() and invalid values 3
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require __DIR__.'/connect.inc';
14
15$drop = "DROP table bind_test";
16$statement = oci_parse($c, $drop);
17@oci_execute($statement);
18
19$create = "CREATE table bind_test(name DATE)";
20$statement = oci_parse($c, $create);
21oci_execute($statement);
22
23$create_pkg = "
24CREATE OR REPLACE PACKAGE ARRAY_BIND_003_PKG AS
25  TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
26  PROCEDURE iobind(c1 IN OUT ARRTYPE);
27END ARRAY_BIND_003_PKG;";
28$statement = oci_parse($c, $create_pkg);
29oci_execute($statement);
30
31$create_pkg_body = "
32CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_003_PKG AS
33  CURSOR CUR IS SELECT name FROM bind_test;
34  PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
35    BEGIN
36    FOR i IN 1..5 LOOP
37      INSERT INTO bind_test VALUES (c1(i));
38    END LOOP;
39    IF NOT CUR%ISOPEN THEN
40      OPEN CUR;
41    END IF;
42    FOR i IN REVERSE 1..5 LOOP
43      FETCH CUR INTO c1(i);
44      IF CUR%NOTFOUND THEN
45        CLOSE CUR;
46        EXIT;
47      END IF;
48    END LOOP;
49  END iobind;
50END ARRAY_BIND_003_PKG;";
51$statement = oci_parse($c, $create_pkg_body);
52oci_execute($statement);
53
54$statement = oci_parse($c, "BEGIN array_bind_003_pkg.iobind(:c1); END;");
55
56$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17");
57
58oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_ODT);
59
60oci_execute($statement);
61
62var_dump($array);
63
64echo "Done\n";
65?>
66--EXPECTF--
67Warning: oci_execute(): ORA-01403: %s
68ORA-06512: at "%s.ARRAY_BIND_003_PKG", line %d
69ORA-06512: at line %d in %sarray_bind_003.php on line %d
70array(4) {
71  [0]=>
72  string(9) "06-DEC-05"
73  [1]=>
74  string(9) "10-DEC-80"
75  [2]=>
76  string(9) "21-AUG-91"
77  [3]=>
78  string(9) "26-OCT-17"
79}
80Done
81