imp_res_4.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: oci_fetch
  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_4_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_4_proc(); end;");
  34. oci_execute($s);
  35. oci_fetch($s); // This will fail with ORA-24374
  36. var_dump(oci_result($s, 1));
  37. echo "\nTest 2\n";
  38. $s = oci_parse($c, "begin imp_res_4_proc(); end;");
  39. oci_execute($s);
  40. $r = oci_fetch_row($s);
  41. var_dump($r);
  42. oci_fetch($s); // This will fail with ORA-24374
  43. var_dump(oci_result($s, 1));
  44. $r = oci_fetch_row($s);
  45. var_dump($r);
  46. // Clean up
  47. $stmtarray = array(
  48. "drop procedure imp_res_4_proc",
  49. );
  50. oci8_test_sql_execute($c, $stmtarray);
  51. ?>
  52. --EXPECTF--
  53. Test 1
  54. Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
  55. bool(false)
  56. Test 2
  57. array(1) {
  58. [0]=>
  59. string(1) "1"
  60. }
  61. Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
  62. bool(false)
  63. array(1) {
  64. [0]=>
  65. string(1) "2"
  66. }