1--TEST-- 2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test 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_1_tab_1", 28 "create table imp_res_get_1_tab_1 (c1 number, c2 varchar2(10))", 29 "insert into imp_res_get_1_tab_1 values (1, 'abcde')", 30 "insert into imp_res_get_1_tab_1 values (2, 'fghij')", 31 "insert into imp_res_get_1_tab_1 values (3, 'klmno')", 32 33 "drop table imp_res_get_1_tab_2", 34 "create table imp_res_get_1_tab_2 (c3 varchar2(1))", 35 "insert into imp_res_get_1_tab_2 values ('t')", 36 "insert into imp_res_get_1_tab_2 values ('u')", 37 "insert into imp_res_get_1_tab_2 values ('v')", 38 39 "create or replace procedure imp_res_get_1_proc as 40 c1 sys_refcursor; 41 begin 42 open c1 for select * from imp_res_get_1_tab_1 order by 1; 43 dbms_sql.return_result(c1); 44 45 open c1 for select * from imp_res_get_1_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$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); 59oci_execute($s); 60while (($s1 = oci_get_implicit_resultset($s))) { 61 while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { 62 foreach ($row as $item) { 63 echo " ".$item; 64 } 65 echo "\n"; 66 } 67} 68 69echo "\nTest 2 - with execute\n"; 70$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); 71oci_execute($s); 72while (($s1 = oci_get_implicit_resultset($s))) { 73 oci_execute($s1); // no op 74 while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { 75 foreach ($row as $item) { 76 echo " ".$item; 77 } 78 echo "\n"; 79 } 80} 81 82// Clean up 83 84$stmtarray = array( 85 "drop procedure imp_res_get_1_proc", 86 "drop table imp_res_get_1_tab_1", 87 "drop table imp_res_get_1_tab_2" 88); 89 90oci8_test_sql_execute($c, $stmtarray); 91 92?> 93--EXPECT-- 94Test 1 95 1 abcde 96 2 fghij 97 3 klmno 98 t 99 u 100 X 101 102Test 2 - with execute 103 1 abcde 104 2 fghij 105 3 klmno 106 t 107 u 108 X 109