php man page for sqlsrv_cancel

Query: sqlsrv_cancel

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

SQLSRV_CANCEL(3)														  SQLSRV_CANCEL(3)

sqlsrv_cancel - Cancels a statement

SYNOPSIS
bool sqlsrv_cancel (resource $stmt)
DESCRIPTION
Cancels a statement. Any results associated with the statement that have not been consumed are deleted. After sqlsrv_cancel(3) has been called, the specified statement can be re-executed if it was created with sqlsrv_prepare(3). Calling sqlsrv_cancel(3) is not necessary if all the results associated with the statement have been consumed.
PARAMETERS
o $stmt - The statement resource to be cancelled.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1 sqlsrv_cancel(3) example <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); } $sql = "SELECT Sales FROM Table_1"; $stmt = sqlsrv_prepare( $conn, $sql); if( $stmt === false ) { die( print_r( sqlsrv_errors(), true)); } if( sqlsrv_execute( $stmt ) === false) { die( print_r( sqlsrv_errors(), true)); } $salesTotal = 0; $count = 0; while( ($row = sqlsrv_fetch_array( $stmt)) && $salesTotal <=100000) { $qty = $row[0]; $price = $row[1]; $salesTotal += ( $price * $qty); $count++; } echo "$count sales accounted for the first $$salesTotal in revenue.<br />"; // Cancel the pending results. The statement can be reused. sqlsrv_cancel( $stmt); ?>
NOTES
The main difference between sqlsrv_cancel(3) and sqlsrv_free_stmt(3) is that a statement resource cancelled with sqlsrv_cancel(3) can be re-executed if it was created with sqlsrv_prepare(3). A statement resource cancelled with sqlsrv_free_statement(3) cannot be re-executed.
SEE ALSO
sqlsrv_free_stmt(3), sqlsrv_prepare(3). PHP Documentation Group SQLSRV_CANCEL(3)
Related Man Pages
sqlsrv_connect(3) - php
sqlsrv_send_stream_data(3) - php
sqlsrv_execute(3) - php
sqlsrv_fetch_object(3) - php
sqlsrv_next_result(3) - php
Similar Topics in the Unix Linux Community
What is $$
sqlplus: could it be dirrected do not printout anything, beside results?
Select variable within a if statement
If statement is not working in KSH
Multiple conditions inside my if statement