imp_res_close.phpt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: oci_free_statement #1
  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_close_proc as
  24. c1 sys_refcursor;
  25. begin
  26. open c1 for select 1 from dual union all select 2 from dual order by 1;
  27. dbms_sql.return_result(c1);
  28. open c1 for select 3 from dual union all select 4 from dual order by 1;
  29. dbms_sql.return_result(c1);
  30. open c1 for select 5 from dual union all select 6 from dual order by 1;
  31. dbms_sql.return_result(c1);
  32. end;"
  33. );
  34. oci8_test_sql_execute($c, $stmtarray);
  35. // Run Test
  36. echo "Test 1\n";
  37. $s = oci_parse($c, "begin imp_res_close_proc(); end;");
  38. oci_execute($s);
  39. try {
  40. while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
  41. foreach ($row as $item) {
  42. echo " ".$item;
  43. }
  44. echo "\n";
  45. oci_free_statement($s); // Free the implicit result handle
  46. }
  47. } catch(\TypeError $exception) {
  48. var_dump($exception->getMessage());
  49. }
  50. // Clean up
  51. $stmtarray = array(
  52. "drop procedure imp_res_close_proc"
  53. );
  54. oci8_test_sql_execute($c, $stmtarray);
  55. ?>
  56. --EXPECTF--
  57. Test 1
  58. 1
  59. string(%d) "oci_fetch_array(): supplied resource is not a valid oci8 statement resource"