cursors_old.phpt 1.4 KB

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