Annotation of embedaddon/php/ext/oci8/tests/array_bind_011.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: oci_bind_array_by_name(), SQLT_CHR, default max_length and empty array
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: require dirname(__FILE__).'/connect.inc';
! 9:
! 10: $drop = "DROP table bind_test";
! 11: $statement = oci_parse($c, $drop);
! 12: @oci_execute($statement);
! 13:
! 14: $create = "CREATE table bind_test(name VARCHAR(20))";
! 15: $statement = oci_parse($c, $create);
! 16: oci_execute($statement);
! 17:
! 18: $create_pkg = "
! 19: CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
! 20: TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
! 21: PROCEDURE iobind(c1 IN OUT ARRTYPE);
! 22: END ARRAYBINDPKG1;";
! 23: $statement = oci_parse($c, $create_pkg);
! 24: oci_execute($statement);
! 25:
! 26: $create_pkg_body = "
! 27: CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
! 28: CURSOR CUR IS SELECT name FROM bind_test;
! 29: PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
! 30: BEGIN
! 31: FOR i IN 1..5 LOOP
! 32: INSERT INTO bind_test VALUES (c1(i));
! 33: END LOOP;
! 34: IF NOT CUR%ISOPEN THEN
! 35: OPEN CUR;
! 36: END IF;
! 37: FOR i IN REVERSE 1..5 LOOP
! 38: FETCH CUR INTO c1(i);
! 39: IF CUR%NOTFOUND THEN
! 40: CLOSE CUR;
! 41: EXIT;
! 42: END IF;
! 43: END LOOP;
! 44: END iobind;
! 45: END ARRAYBINDPKG1;";
! 46: $statement = oci_parse($c, $create_pkg_body);
! 47: oci_execute($statement);
! 48:
! 49: $statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
! 50:
! 51: $array = array();
! 52:
! 53: oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_CHR);
! 54:
! 55: oci_execute($statement);
! 56:
! 57: var_dump($array);
! 58:
! 59: echo "Done\n";
! 60: ?>
! 61: --EXPECTF--
! 62: Warning: oci_bind_array_by_name(): You must provide max length value for empty arrays in %s on line %d
! 63:
! 64: Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
! 65: array(0) {
! 66: }
! 67: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>