1--TEST-- 2oci_bind_array_by_name() and SQLT_FLT 3--SKIPIF-- 4<?php 5$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 6require(__DIR__.'/skipif.inc'); 7?> 8--FILE-- 9<?php 10 11require __DIR__.'/connect.inc'; 12 13$drop = "DROP table bind_test"; 14$statement = oci_parse($c, $drop); 15@oci_execute($statement); 16 17$create = "CREATE table bind_test(name FLOAT)"; 18$statement = oci_parse($c, $create); 19oci_execute($statement); 20 21$create_pkg = " 22CREATE OR REPLACE PACKAGE ARRAY_BIND_FLOAT_PKG AS 23 TYPE ARRTYPE IS TABLE OF FLOAT INDEX BY BINARY_INTEGER; 24 PROCEDURE iobind(c1 IN OUT ARRTYPE); 25END ARRAY_BIND_FLOAT_PKG;"; 26$statement = oci_parse($c, $create_pkg); 27oci_execute($statement); 28 29$create_pkg_body = " 30CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_FLOAT_PKG AS 31 CURSOR CUR IS SELECT name FROM bind_test; 32 PROCEDURE iobind(c1 IN OUT ARRTYPE) IS 33 BEGIN 34 FOR i IN 1..5 LOOP 35 INSERT INTO bind_test VALUES (c1(i)); 36 END LOOP; 37 IF NOT CUR%ISOPEN THEN 38 OPEN CUR; 39 END IF; 40 FOR i IN REVERSE 1..5 LOOP 41 FETCH CUR INTO c1(i); 42 IF CUR%NOTFOUND THEN 43 CLOSE CUR; 44 EXIT; 45 END IF; 46 END LOOP; 47 END iobind; 48END ARRAY_BIND_FLOAT_PKG;"; 49$statement = oci_parse($c, $create_pkg_body); 50oci_execute($statement); 51 52$statement = oci_parse($c, "BEGIN array_bind_float_pkg.iobind(:c1); END;"); 53 54$array = Array(1.243,2.5658,3.4234,4.2123,5.9999); 55 56oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_FLT); 57 58oci_execute($statement); 59 60var_dump($array); 61 62echo "Done\n"; 63?> 64--EXPECTF-- 65array(5) { 66 [0]=> 67 float(5.9999) 68 [1]=> 69 float(4.2123) 70 [2]=> 71 float(3.4234) 72 [3]=> 73 float(2.5658%S) 74 [4]=> 75 float(1.243) 76} 77Done 78