xref: /PHP-8.1/ext/oci8/tests/bug40078.phpt (revision b5a14e6c)
1--TEST--
2Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name())
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$create_pkg = "
16CREATE OR REPLACE PACKAGE BUG40078_PKG AS
17    TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
18    PROCEDURE nullbind(c1 OUT ARRTYPE);
19END BUG40078_PKG;";
20$statement = oci_parse($c, $create_pkg);
21oci_execute($statement);
22
23$create_pkg_body = "
24CREATE OR REPLACE PACKAGE BODY BUG40078_PKG AS
25    PROCEDURE nullbind(c1 OUT ARRTYPE) IS
26    BEGIN
27        c1(1) := 'one';
28        c1(2) := 'two';
29        c1(3) := '';
30        c1(4) := 'four';
31        c1(5) := 'five';
32    END nullbind;
33END BUG40078_PKG;";
34$statement = oci_parse($c, $create_pkg_body);
35oci_execute($statement);
36
37$statement = oci_parse($c, "BEGIN bug40078_pkg.nullbind(:c1); END;");
38
39oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR);
40
41oci_execute($statement);
42
43var_dump($array);
44
45echo "Done\n";
46?>
47--EXPECT--
48array(5) {
49  [0]=>
50  string(3) "one"
51  [1]=>
52  string(3) "two"
53  [2]=>
54  string(0) ""
55  [3]=>
56  string(4) "four"
57  [4]=>
58  string(4) "five"
59}
60Done
61