1--TEST-- 2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: similar to imp_res_get_1 but with unrolled loop 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 9require __DIR__.'/skipif.inc'; 10preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); 11if (!(isset($matches[0]) && $matches[1] >= 12)) { 12 die("skip expected output only valid when using Oracle Database 12c or greater"); 13} 14preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); 15if (!(isset($matches[0]) && $matches[0] >= 12)) { 16 die("skip works only with Oracle 12c or greater version of Oracle client libraries"); 17} 18?> 19--FILE-- 20<?php 21 22require __DIR__.'/connect.inc'; 23 24// Initialization 25 26$stmtarray = array( 27 "drop table imp_res_get_2_tab_1", 28 "create table imp_res_get_2_tab_1 (c1 number, c2 varchar2(10))", 29 "insert into imp_res_get_2_tab_1 values (1, 'abcde')", 30 "insert into imp_res_get_2_tab_1 values (2, 'fghij')", 31 "insert into imp_res_get_2_tab_1 values (3, 'klmno')", 32 33 "drop table imp_res_get_2_tab_2", 34 "create table imp_res_get_2_tab_2 (c3 varchar2(1))", 35 "insert into imp_res_get_2_tab_2 values ('t')", 36 "insert into imp_res_get_2_tab_2 values ('u')", 37 "insert into imp_res_get_2_tab_2 values ('v')", 38 39 "create or replace procedure imp_res_get_2_proc as 40 c1 sys_refcursor; 41 begin 42 open c1 for select * from imp_res_get_2_tab_1 order by 1; 43 dbms_sql.return_result(c1); 44 45 open c1 for select * from imp_res_get_2_tab_2 where rownum < 3 order by 1; 46 dbms_sql.return_result(c1); 47 48 open c1 for select * from dual; 49 dbms_sql.return_result (c1); 50 end;" 51); 52 53oci8_test_sql_execute($c, $stmtarray); 54 55// Run Test 56 57echo "Test 1\n"; 58 59$s = oci_parse($c, "begin imp_res_get_2_proc(); end;"); 60oci_execute($s); 61 62$s1 = oci_get_implicit_resultset($s); 63while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS))) { 64 foreach ($row as $item) { 65 echo " ".$item; 66 } 67 echo "\n"; 68} 69 70$s2 = oci_get_implicit_resultset($s); 71while (($row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS))) { 72 foreach ($row as $item) { 73 echo " ".$item; 74 } 75 echo "\n"; 76} 77oci_free_statement($s2); 78 79$s3 = oci_get_implicit_resultset($s); 80while (($row = oci_fetch_array($s3, OCI_ASSOC+OCI_RETURN_NULLS))) { 81 foreach ($row as $item) { 82 echo " ".$item; 83 } 84 echo "\n"; 85} 86oci_free_statement($s3); 87 88// Clean up 89 90$stmtarray = array( 91 "drop procedure imp_res_get_2_proc", 92 "drop table imp_res_get_2_tab_1", 93 "drop table imp_res_get_2_tab_2" 94); 95 96oci8_test_sql_execute($c, $stmtarray); 97 98?> 99--EXPECT-- 100Test 1 101 1 abcde 102 2 fghij 103 3 klmno 104 t 105 u 106 X 107