cursor_bind.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. bind and fetch cursor from a statement
  3. --SKIPIF--
  4. <?php
  5. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  6. require(dirname(__FILE__).'/skipif.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require(dirname(__FILE__)."/connect.inc");
  11. // Initialization
  12. $stmtarray = array(
  13. "drop table cursor_bind_tab",
  14. "create table cursor_bind_tab (id NUMBER, value VARCHAR(20))",
  15. "insert into cursor_bind_tab values (1, '1')",
  16. "insert into cursor_bind_tab values (1, '1')",
  17. "insert into cursor_bind_tab values (1, '1')"
  18. );
  19. oci8_test_sql_execute($c, $stmtarray);
  20. $sql = "
  21. DECLARE
  22. TYPE curtype IS REF CURSOR;
  23. cursor_var curtype;
  24. BEGIN
  25. OPEN cursor_var FOR SELECT id, value FROM cursor_bind_tab;
  26. :curs := cursor_var;
  27. END;
  28. ";
  29. $stmt = oci_parse($c, $sql);
  30. $cursor = oci_new_cursor($c);
  31. oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR);
  32. oci_execute($stmt);
  33. oci_execute($cursor);
  34. var_dump(oci_fetch_row($cursor));
  35. var_dump(oci_fetch_row($cursor));
  36. var_dump(oci_fetch_row($cursor));
  37. var_dump(oci_fetch_row($cursor));
  38. // Clean up
  39. $stmtarray = array(
  40. "drop table cursor_bind_tab"
  41. );
  42. oci8_test_sql_execute($c, $stmtarray);
  43. ?>
  44. ===DONE===
  45. <?php exit(0); ?>
  46. --EXPECT--
  47. array(2) {
  48. [0]=>
  49. string(1) "1"
  50. [1]=>
  51. string(1) "1"
  52. }
  53. array(2) {
  54. [0]=>
  55. string(1) "1"
  56. [1]=>
  57. string(1) "1"
  58. }
  59. array(2) {
  60. [0]=>
  61. string(1) "1"
  62. [1]=>
  63. string(1) "1"
  64. }
  65. bool(false)
  66. ===DONE===