Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : IBM DB2, Cloudscape and Apache Derby Functions : db2_next_result

db2_next_result

Requests the next result set from a stored procedure (PECL ibm_db2:1.0-1.6.2)
resource db2_next_result ( resource stmt )

Example 946. Calling a stored procedure that returns multiple result sets

In the following example, we call a stored procedure that returns three result sets. The first result set is fetched directly from the same statement resource on which we invoked the CALL statement, while the second and third result sets are fetched from statement resources returned from our calls to the db2_next_result() function.

<?php
$conn
= db2_connect($database, $user, $password);

if (
$conn) {
 
$stmt = db2_exec($conn, 'CALL multiResults()');

 print
"Fetching first result set\n";
 while (
$row = db2_fetch_array($stmt)) {
   
var_dump($row);
 }

 print
"\nFetching second result set\n";
 
$res = db2_next_result($stmt);
 if (
$res) {
   while (
$row = db2_fetch_array($res)) {
     
var_dump($row);
   }
 }

 print
"\nFetching third result set\n";
 
$res2 = db2_next_result($stmt);
 if (
$res2) {
   while (
$row = db2_fetch_array($res2)) {
     
var_dump($row);
   }
 }

 
db2_close($conn);
}
?>

The above example will output:

Fetching first result set
array(2) {
 [0]=>
 string(16) "Bubbles         "
 [1]=>
 int(3)
}
array(2) {
 [0]=>
 string(16) "Gizmo           "
 [1]=>
 int(4)
}

Fetching second result set
array(4) {
 [0]=>
 string(16) "Sweater         "
 [1]=>
 int(6)
 [2]=>
 string(5) "llama"
 [3]=>
 string(6) "150.00"
}
array(4) {
 [0]=>
 string(16) "Smarty          "
 [1]=>
 int(2)
 [2]=>
 string(5) "horse"
 [3]=>
 string(6) "350.00"
}

Fetching third result set
array(1) {
 [0]=>
 string(16) "Bubbles         "
}
array(1) {
 [0]=>
 string(16) "Gizmo           "
}

Change Language


Follow Navioo On Twitter
db2_autocommit
db2_bind_param
db2_client_info
db2_close
db2_column_privileges
db2_columns
db2_commit
db2_conn_error
db2_conn_errormsg
db2_connect
db2_cursor_type
db2_escape_string
db2_exec
db2_execute
db2_fetch_array
db2_fetch_assoc
db2_fetch_both
db2_fetch_object
db2_fetch_row
db2_field_display_size
db2_field_name
db2_field_num
db2_field_precision
db2_field_scale
db2_field_type
db2_field_width
db2_foreign_keys
db2_free_result
db2_free_stmt
db2_get_option
db2_lob_read
db2_next_result
db2_num_fields
db2_num_rows
db2_pconnect
db2_prepare
db2_primary_keys
db2_procedure_columns
db2_procedures
db2_result
db2_rollback
db2_server_info
db2_set_option
db2_special_columns
db2_statistics
db2_stmt_error
db2_stmt_errormsg
db2_table_privileges
db2_tables
eXTReMe Tracker