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