imp_res_2.phpt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: Zero Rows
  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_2_proc_a as
  24. c1 sys_refcursor;
  25. begin
  26. open c1 for select * from dual where 1 = 0;
  27. dbms_sql.return_result(c1);
  28. end;",
  29. "create or replace procedure imp_res_2_proc_b as
  30. c1 sys_refcursor;
  31. begin
  32. open c1 for select * from dual;
  33. dbms_sql.return_result(c1);
  34. open c1 for select * from dual where 1 = 0;
  35. dbms_sql.return_result(c1);
  36. end;",
  37. "create or replace procedure imp_res_2_proc_c as
  38. c1 sys_refcursor;
  39. begin
  40. open c1 for select * from dual where 1 = 0;
  41. dbms_sql.return_result(c1);
  42. open c1 for select * from dual;
  43. dbms_sql.return_result(c1);
  44. end;"
  45. );
  46. oci8_test_sql_execute($c, $stmtarray);
  47. // Run Test
  48. echo "Test 1\n";
  49. $s = oci_parse($c, "begin imp_res_2_proc_a(); end;");
  50. oci_execute($s);
  51. while (($row = oci_fetch_row($s)) != false)
  52. var_dump($row);
  53. echo "Test 2\n";
  54. $s = oci_parse($c, "begin imp_res_2_proc_b(); end;");
  55. oci_execute($s);
  56. while (($row = oci_fetch_row($s)) != false)
  57. var_dump($row);
  58. echo "Test 2\n";
  59. $s = oci_parse($c, "begin imp_res_2_proc_c(); end;");
  60. oci_execute($s);
  61. while (($row = oci_fetch_row($s)) != false)
  62. var_dump($row);
  63. // Clean up
  64. $stmtarray = array(
  65. "drop procedure imp_res_2_proc_a",
  66. "drop procedure imp_res_2_proc_b",
  67. "drop procedure imp_res_2_proc_c"
  68. );
  69. oci8_test_sql_execute($c, $stmtarray);
  70. ?>
  71. --EXPECT--
  72. Test 1
  73. Test 2
  74. array(1) {
  75. [0]=>
  76. string(1) "X"
  77. }
  78. Test 2
  79. array(1) {
  80. [0]=>
  81. string(1) "X"
  82. }