ff pereira
ff pereira

Reputation: 43

Executing Stored Procedure with sqlsrv in PHP

I'm executing a stored procedure using sqlsrv in a php code like this:

    $tsql_callSP = "{call cnt.stproc1(?)}";
    $rotCode = '1111';
    $params = array( 
                     array($rotCode, SQLSRV_PARAM_IN),
                   );

    $serverName = "xxxxxxx\wwwwwww"; //serverName\instanceName
    $connectionInfo = array( "Database"=>"aaaaaaaaaaa", "UID"=>"bbbbbbb", "PWD"=>"ccccccc");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    /* Execute the query. */
    $stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params);
    if( $stmt3 === false )
    {
         echo "Error in executing statement 3.\n";
         die( print_r( sqlsrv_errors(), true));
    }

The Stored Procedure is executed in the DB successfully and does what it has to do, but in my php code i always fall in the failiure if (stmt3 === false) receiving the following error:

     Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]0510620150922777 ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]UPDATE 004 ) )

What is wrong here? why does it get executed well, but the driver handles me this error?

Upvotes: 0

Views: 1948

Answers (1)

ff pereira
ff pereira

Reputation: 43

Done. It was not an error, just a warning. However, sqlsrv treats warnings as errors unless told otherwise with:

    sqlsrv_configure("WarningsReturnAsErrors", 0);

Thanks anyway.

Upvotes: 1

Related Questions