xref: /PHP-7.2/ext/oci8/tests/cursors_old.phpt (revision a2c0f872)
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");
12
13// Initialize
14
15$stmtarray = array(
16    "drop table cursors_old_tab",
17    "create table cursors_old_tab (id number, value number)",
18    "insert into cursors_old_tab (id, value) values (1,1)",
19    "insert into cursors_old_tab (id, value) values (1,1)",
20    "insert into cursors_old_tab (id, value) values (1,1)",
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25// Run Test
26
27$sql = "select cursor(select * from cursors_old_tab) as curs from dual";
28$stmt = ociparse($c, $sql);
29
30ociexecute($stmt);
31
32while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) {
33	ociexecute($data["CURS"]);
34	ocifetchinto($data["CURS"], $subdata, OCI_ASSOC);
35	var_dump($subdata);
36	var_dump(ocicancel($data["CURS"]));
37	ocifetchinto($data["CURS"], $subdata, OCI_ASSOC);
38	var_dump($subdata);
39	var_dump(ocicancel($data["CURS"]));
40}
41
42// Cleanup
43
44$stmtarray = array(
45    "drop table cursors_old_tab"
46);
47
48oci8_test_sql_execute($c, $stmtarray);
49
50echo "Done\n";
51
52?>
53--EXPECTF--
54array(2) {
55  ["ID"]=>
56  string(1) "1"
57  ["VALUE"]=>
58  string(1) "1"
59}
60bool(true)
61
62Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d
63array(2) {
64  ["ID"]=>
65  string(1) "1"
66  ["VALUE"]=>
67  string(1) "1"
68}
69bool(true)
70Done
71