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