xref: /PHP-5.6/ext/oci8/tests/cursors.phpt (revision c7a8bd6a)
1--TEST--
2fetching cursor from a statement
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";
12require dirname(__FILE__)."/create_table.inc";
13
14$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
15
16if (!($s = oci_parse($c, $insert_sql))) {
17	die("oci_parse(insert) failed!\n");
18}
19
20for ($i = 0; $i<3; $i++) {
21	if (!oci_execute($s)) {
22		die("oci_execute(insert) failed!\n");
23	}
24}
25
26if (!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
33oci_execute($stmt);
34
35while ($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
45require dirname(__FILE__)."/drop_table.inc";
46
47echo "Done\n";
48
49?>
50--EXPECTF--
51array(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}
63bool(true)
64
65Warning: oci_fetch_assoc(): ORA-01002: fetch out of sequence in %s on line %d
66bool(false)
67bool(true)
68Done
69