Annotation of embedaddon/php/ext/oci8/tests/cursors.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: fetching cursor from a statement
! 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: require dirname(__FILE__)."/create_table.inc";
! 13:
! 14: $insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
! 15:
! 16: if (!($s = oci_parse($c, $insert_sql))) {
! 17: die("oci_parse(insert) failed!\n");
! 18: }
! 19:
! 20: for ($i = 0; $i<3; $i++) {
! 21: if (!oci_execute($s)) {
! 22: die("oci_execute(insert) failed!\n");
! 23: }
! 24: }
! 25:
! 26: if (!oci_commit($c)) {
! 27: die("oci_commit() failed!\n");
! 28: }
! 29:
! 30: $sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual";
! 31: $stmt = oci_parse($c, $sql);
! 32:
! 33: oci_execute($stmt);
! 34:
! 35: while ($data = oci_fetch_assoc($stmt)) {
! 36: oci_execute($data["CURS"]);
! 37: $subdata = oci_fetch_assoc($data["CURS"]);
! 38: var_dump($subdata);
! 39: var_dump(oci_cancel($data["CURS"]));
! 40: $subdata = oci_fetch_assoc($data["CURS"]);
! 41: var_dump($subdata);
! 42: var_dump(oci_cancel($data["CURS"]));
! 43: }
! 44:
! 45: require dirname(__FILE__)."/drop_table.inc";
! 46:
! 47: echo "Done\n";
! 48:
! 49: ?>
! 50: --EXPECTF--
! 51: array(5) {
! 52: ["ID"]=>
! 53: string(1) "1"
! 54: ["VALUE"]=>
! 55: string(1) "1"
! 56: ["BLOB"]=>
! 57: NULL
! 58: ["CLOB"]=>
! 59: NULL
! 60: ["STRING"]=>
! 61: NULL
! 62: }
! 63: bool(true)
! 64:
! 65: Warning: oci_fetch_assoc(): ORA-01002: fetch out of sequence in %s on line %d
! 66: bool(false)
! 67: bool(true)
! 68: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>