array_bind_002.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. oci_bind_array_by_name() and invalid values 2
  3. --SKIPIF--
  4. <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
  5. --FILE--
  6. <?php
  7. require dirname(__FILE__).'/connect.inc';
  8. $drop = "DROP table bind_test";
  9. $statement = oci_parse($c, $drop);
  10. @oci_execute($statement);
  11. $create = "CREATE table bind_test(name DATE)";
  12. $statement = oci_parse($c, $create);
  13. oci_execute($statement);
  14. $create_pkg = "
  15. CREATE OR REPLACE PACKAGE ARRAY_BIND_002_PKG AS
  16. TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
  17. PROCEDURE iobind(c1 IN OUT ARRTYPE);
  18. END ARRAY_BIND_002_PKG;";
  19. $statement = oci_parse($c, $create_pkg);
  20. oci_execute($statement);
  21. $create_pkg_body = "
  22. CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_002_PKG AS
  23. CURSOR CUR IS SELECT name FROM bind_test;
  24. PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
  25. BEGIN
  26. FOR i IN 1..5 LOOP
  27. INSERT INTO bind_test VALUES (c1(i));
  28. END LOOP;
  29. IF NOT CUR%ISOPEN THEN
  30. OPEN CUR;
  31. END IF;
  32. FOR i IN REVERSE 1..5 LOOP
  33. FETCH CUR INTO c1(i);
  34. IF CUR%NOTFOUND THEN
  35. CLOSE CUR;
  36. EXIT;
  37. END IF;
  38. END LOOP;
  39. END iobind;
  40. END ARRAY_BIND_002_PKG;";
  41. $statement = oci_parse($c, $create_pkg_body);
  42. oci_execute($statement);
  43. $statement = oci_parse($c, "BEGIN array_bind_002_pkg.iobind(:c1); END;");
  44. $array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
  45. oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT);
  46. oci_execute($statement);
  47. var_dump($array);
  48. echo "Done\n";
  49. ?>
  50. --EXPECTF--
  51. Warning: oci_bind_array_by_name(): Maximum array length must be greater than zero in %s on line %d
  52. Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
  53. array(5) {
  54. [0]=>
  55. string(9) "06-DEC-05"
  56. [1]=>
  57. string(9) "10-DEC-80"
  58. [2]=>
  59. string(9) "21-AUG-91"
  60. [3]=>
  61. string(9) "26-OCT-17"
  62. [4]=>
  63. string(9) "05-NOV-05"
  64. }
  65. Done