xref: /PHP-8.3/ext/oci8/tests/array_bind_007.phpt (revision a53e5617)
1--TEST--
2oci_bind_array_by_name() and invalid values 7
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 NUMBER)";
19$statement = oci_parse($c, $create);
20oci_execute($statement);
21
22$create_pkg = "
23CREATE OR REPLACE PACKAGE ARRAY_BIND_007_PKG AS
24  TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
25  PROCEDURE iobind(c1 IN OUT ARRTYPE);
26END ARRAY_BIND_007_PKG;";
27$statement = oci_parse($c, $create_pkg);
28oci_execute($statement);
29
30$create_pkg_body = "
31CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_007_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_007_PKG;";
50$statement = oci_parse($c, $create_pkg_body);
51oci_execute($statement);
52
53$statement = oci_parse($c, "BEGIN array_bind_007_pkg.iobind(:c1); END;");
54
55$array = Array(1,2,3,4,5);
56
57oci_bind_array_by_name($statement, ":c1", $array, 5, 5, -1);
58
59oci_execute($statement);
60
61var_dump($array);
62
63echo "Done\n";
64?>
65--EXPECTF--
66Warning: oci_bind_array_by_name(): Unknown or unsupported datatype given: -1 in %s on line %d
67
68Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
69array(5) {
70  [0]=>
71  int(1)
72  [1]=>
73  int(2)
74  [2]=>
75  int(3)
76  [3]=>
77  int(4)
78  [4]=>
79  int(5)
80}
81Done
82