1--TEST-- 2bind and fetch cursor from a statement 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 8require(__DIR__.'/skipif.inc'); 9?> 10--FILE-- 11<?php 12 13require(__DIR__."/connect.inc"); 14 15// Initialization 16 17$stmtarray = array( 18 "drop table cursor_bind_tab", 19 "create table cursor_bind_tab (id NUMBER, value VARCHAR(20))", 20 "insert into cursor_bind_tab values (1, '1')", 21 "insert into cursor_bind_tab values (1, '1')", 22 "insert into cursor_bind_tab values (1, '1')" 23); 24 25oci8_test_sql_execute($c, $stmtarray); 26 27$sql = " 28DECLARE 29TYPE curtype IS REF CURSOR; 30cursor_var curtype; 31BEGIN 32 OPEN cursor_var FOR SELECT id, value FROM cursor_bind_tab; 33 :curs := cursor_var; 34END; 35"; 36 37$stmt = oci_parse($c, $sql); 38 39$cursor = oci_new_cursor($c); 40oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR); 41 42oci_execute($stmt); 43 44oci_execute($cursor); 45var_dump(oci_fetch_row($cursor)); 46var_dump(oci_fetch_row($cursor)); 47var_dump(oci_fetch_row($cursor)); 48var_dump(oci_fetch_row($cursor)); 49 50// Clean up 51 52$stmtarray = array( 53 "drop table cursor_bind_tab" 54); 55 56oci8_test_sql_execute($c, $stmtarray); 57 58?> 59--EXPECT-- 60array(2) { 61 [0]=> 62 string(1) "1" 63 [1]=> 64 string(1) "1" 65} 66array(2) { 67 [0]=> 68 string(1) "1" 69 [1]=> 70 string(1) "1" 71} 72array(2) { 73 [0]=> 74 string(1) "1" 75 [1]=> 76 string(1) "1" 77} 78bool(false) 79