Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

db2_next_result(3) [php man page]

DB2_NEXT_RESULT(3)							 1							DB2_NEXT_RESULT(3)

db2_next_result - Requests the next result set from a stored procedure

SYNOPSIS
resource db2_next_result (resource $stmt) DESCRIPTION
A stored procedure can return zero or more result sets. While you handle the first result set in exactly the same way you would handle the results returned by a simple SELECT statement, to fetch the second and subsequent result sets from a stored procedure you must call the db2_next_result(3) function and return the result to a uniquely named PHP variable. PARAMETERS
o $stmt - A prepared statement returned from db2_exec(3) or db2_execute(3). RETURN VALUES
Returns a new statement resource containing the next result set if the stored procedure returned another result set. Returns FALSE if the stored procedure did not return another result set. EXAMPLES
Example #1 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 state- ment resources returned from our calls to the db2_next_result(3) function. <?php $conn = db2_connect($database, $user, $password); if ($conn) { $stmt = db2_exec($conn, 'CALL multiResults()'); print "Fetching first result set "; while ($row = db2_fetch_array($stmt)) { var_dump($row); } print " Fetching second result set "; $res = db2_next_result($stmt); if ($res) { while ($row = db2_fetch_array($res)) { var_dump($row); } } print " Fetching third result set "; $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 " } PHP Documentation Group DB2_NEXT_RESULT(3)

Check Out this Related Man Page

SQLSRV_NEXT_RESULT(3)													     SQLSRV_NEXT_RESULT(3)

sqlsrv_next_result - Makes the next result of the specified statement active

SYNOPSIS
mixed sqlsrv_next_result (resource $stmt) DESCRIPTION
Makes the next result of the specified statement active. Results include result sets, row counts, and output parameters. PARAMETERS
o $stmt - The statment on which the next result is being called. RETURN VALUES
Returns TRUE if the next result was successfully retrieved, FALSE if an error occurred, and NULL if there are no more results to retrieve. EXAMPLES
Example #1 sqlsrv_next_result(3) example The following example executes a batch query that inserts into a table and then selects from the table. This produces two results on the statement: one for the rows affected by the INSERT and one for the rows returned by the SELECT. To get to the rows returned by the SELECT, sqlsrv_next_result(3) must be called to move past the first result. <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array("Database"=>"dbName", "UID"=>"userName", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); $query = "INSERT INTO Table_1 (id, data) VALUES (?,?); SELECT * FROM TABLE_1;"; $params = array(1, "some data"); $stmt = sqlsrv_query($conn, $query, $params); // Consume the first result (rows affected by INSERT) without calling sqlsrv_next_result. echo "Rows affected: ".sqlsrv_rows_affected($stmt)."<br />"; // Move to the next result and display results. $next_result = sqlsrv_next_result($stmt); if( $next_result ) { while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)){ echo $row['id'].": ".$row['data']."<br />"; } } elseif( is_null($next_result)) { echo "No more results.<br />"; } else { die(print_r(sqlsrv_errors(), true)); } ?> SEE ALSO
sqlsrv_query(3), sqlsrv_fetch_array(3), sqlsrv_rows_affected(3). PHP Documentation Group SQLSRV_NEXT_RESULT(3)
Man Page