imp_res_get_exec.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: Execute twice
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('oci8')) die ("skip no oci8 extension");
  6. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  7. require(dirname(__FILE__).'/skipif.inc');
  8. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  9. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  10. die("skip expected output only valid when using Oracle Database 12c or greater");
  11. }
  12. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  13. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  14. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  15. }
  16. ?>
  17. --FILE--
  18. <?php
  19. require(dirname(__FILE__).'/connect.inc');
  20. $plsql = "declare
  21. c1 sys_refcursor;
  22. begin
  23. open c1 for select 1 from dual union all select 2 from dual;
  24. dbms_sql.return_result(c1);
  25. end;";
  26. // Run Test
  27. echo "Test 1\n";
  28. $s = oci_parse($c, $plsql);
  29. oci_execute($s);
  30. $s1 = oci_get_implicit_resultset($s);
  31. oci_execute($s1);
  32. oci_execute($s1); // execute twice; should be NOP
  33. while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
  34. foreach ($row as $item) {
  35. echo " ".$item;
  36. }
  37. echo "\n";
  38. }
  39. oci_free_statement($s);
  40. ?>
  41. ===DONE===
  42. <?php exit(0); ?>
  43. --EXPECTF--
  44. Test 1
  45. 1
  46. 2
  47. ===DONE===