xref: /PHP-5.4/ext/oci8/tests/bug40078.phpt (revision c7a8bd6a)
1--TEST--
2Bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name())
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require dirname(__FILE__).'/connect.inc';
12
13$create_pkg = "
14CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
15    TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
16    PROCEDURE nullbind(c1 OUT ARRTYPE);
17END ARRAYBINDPKG1;";
18$statement = oci_parse($c, $create_pkg);
19oci_execute($statement);
20
21$create_pkg_body = "
22CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
23    PROCEDURE nullbind(c1 OUT ARRTYPE) IS
24    BEGIN
25        c1(1) := 'one';
26        c1(2) := 'two';
27        c1(3) := '';
28        c1(4) := 'four';
29        c1(5) := 'five';
30    END nullbind;
31END ARRAYBINDPKG1;";
32$statement = oci_parse($c, $create_pkg_body);
33oci_execute($statement);
34
35$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.nullbind(:c1); END;");
36
37oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR);
38
39oci_execute($statement);
40
41var_dump($array);
42
43echo "Done\n";
44?>
45--EXPECTF--
46array(5) {
47  [0]=>
48  string(3) "one"
49  [1]=>
50  string(3) "two"
51  [2]=>
52  string(0) ""
53  [3]=>
54  string(4) "four"
55  [4]=>
56  string(4) "five"
57}
58Done
59