php-src/ext/oci8/tests/cursors_old.phpt

87 lines
1.8 KiB
Plaintext
Raw Normal View History

2005-12-01 13:39:48 +00:00
--TEST--
fetching cursor from a statement
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
2009-10-02 20:16:59 +00:00
require(dirname(__FILE__)."/connect.inc");
2005-12-01 13:39:48 +00:00
2009-10-02 20:16:59 +00:00
// Initialize
2005-12-01 13:39:48 +00:00
2009-10-02 20:16:59 +00:00
$stmtarray = array(
"drop table cursors_old_tab",
"create table cursors_old_tab (id number, value number)",
"insert into cursors_old_tab (id, value) values (1,1)",
"insert into cursors_old_tab (id, value) values (1,1)",
"insert into cursors_old_tab (id, value) values (1,1)",
);
2005-12-01 13:39:48 +00:00
2009-10-02 20:16:59 +00:00
foreach ($stmtarray as $stmt) {
$s = oci_parse($c, $stmt);
$r = @oci_execute($s);
if (!$r) {
$m = oci_error($s);
if (!in_array($m['code'], array( // ignore expected errors
942 // table or view does not exist
))) {
echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
}
2005-12-01 13:39:48 +00:00
}
}
2009-10-02 20:16:59 +00:00
foreach ($stmtarray as $stmt) {
$s = oci_parse($c, $stmt);
oci_execute($s);
2005-12-01 13:39:48 +00:00
}
2009-10-02 20:16:59 +00:00
// Run Test
$sql = "select cursor(select * from cursors_old_tab) as curs from dual";
2005-12-01 13:39:48 +00:00
$stmt = ociparse($c, $sql);
ociexecute($stmt);
while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) {
ociexecute($data["CURS"]);
ocifetchinto($data["CURS"], $subdata, OCI_ASSOC);
var_dump($subdata);
var_dump(ocicancel($data["CURS"]));
ocifetchinto($data["CURS"], $subdata, OCI_ASSOC);
var_dump($subdata);
var_dump(ocicancel($data["CURS"]));
}
2009-10-02 20:16:59 +00:00
// Cleanup
$stmtarray = array(
"drop table cursors_old_tab"
);
foreach ($stmtarray as $stmt) {
$s = oci_parse($c, $stmt);
oci_execute($s);
}
2005-12-01 13:39:48 +00:00
echo "Done\n";
?>
--EXPECTF--
array(2) {
2009-10-02 20:16:59 +00:00
[%u|b%"ID"]=>
%unicode|string%(1) "1"
[%u|b%"VALUE"]=>
%unicode|string%(1) "1"
2005-12-01 13:39:48 +00:00
}
bool(true)
2009-10-02 20:16:59 +00:00
Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d
2005-12-01 13:39:48 +00:00
array(2) {
2009-10-02 20:16:59 +00:00
[%u|b%"ID"]=>
%unicode|string%(1) "1"
[%u|b%"VALUE"]=>
%unicode|string%(1) "1"
2005-12-01 13:39:48 +00:00
}
bool(true)
Done