Annotation of embedaddon/php/ext/oci8/tests/array_bind_014.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: oci_bind_array_by_name() and NUMBERs
! 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 NUMBER)";
! 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 NUMBER 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: 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: for ($i = 1; $i < 6; $i++) {
! 50: $statement = oci_parse($c, "INSERT INTO bind_test VALUES (".$i.")");
! 51: oci_execute($statement);
! 52: }
! 53:
! 54: $statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
! 55: $array = Array();
! 56: oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_INT);
! 57: oci_execute($statement);
! 58:
! 59: var_dump($array);
! 60:
! 61: echo "Done\n";
! 62: ?>
! 63: --EXPECTF--
! 64: array(5) {
! 65: [0]=>
! 66: int(5)
! 67: [1]=>
! 68: int(4)
! 69: [2]=>
! 70: int(3)
! 71: [3]=>
! 72: int(2)
! 73: [4]=>
! 74: int(1)
! 75: }
! 76: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>