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