imp_res_5.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: oci_fetch_all
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  10. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  11. die("skip expected output only valid when using Oracle Database 12c or greater");
  12. }
  13. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  14. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  15. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  16. }
  17. ?>
  18. --FILE--
  19. <?php
  20. require(__DIR__.'/connect.inc');
  21. // Initialization
  22. $stmtarray = array(
  23. "create or replace procedure imp_res_5_proc as
  24. c1 sys_refcursor;
  25. begin
  26. open c1 for select 1 from dual union select 2 from dual;
  27. dbms_sql.return_result (c1);
  28. end;"
  29. );
  30. oci8_test_sql_execute($c, $stmtarray);
  31. // Run Test
  32. echo "Test 1\n";
  33. $s = oci_parse($c, "begin imp_res_5_proc(); end;");
  34. oci_execute($s);
  35. oci_fetch_all($s,$res); // This will fail with ORA-24374
  36. var_dump($res);
  37. echo "\nTest 2\n";
  38. $s = oci_parse($c, "begin imp_res_5_proc(); end;");
  39. oci_execute($s);
  40. $r = oci_fetch_row($s);
  41. var_dump($r);
  42. oci_fetch_all($s, $res); // This will fail with ORA-24374
  43. var_dump($res);
  44. $r = oci_fetch_row($s);
  45. var_dump($r);
  46. // Clean up
  47. $stmtarray = array(
  48. "drop procedure imp_res_5_proc",
  49. );
  50. oci8_test_sql_execute($c, $stmtarray);
  51. ?>
  52. --EXPECTF--
  53. Test 1
  54. Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d
  55. array(0) {
  56. }
  57. Test 2
  58. array(1) {
  59. [0]=>
  60. string(1) "1"
  61. }
  62. Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d
  63. array(0) {
  64. }
  65. array(1) {
  66. [0]=>
  67. string(1) "2"
  68. }