none
Output parameter in stored procedure RRS feed

  • Question

  • Hi,

    I am call stored procedure from PHP and using the following codes:

    $AssessmentID = 0;

    $params = array(

    array($ShopPostCode, $GrossProfit, $LevyDue,$PartYear,$FromDate,$ToDate,

    $ClosedInYear, $OpenedInYear,$BookmakerRef, $Scheme, 

           $AssessedActivityID, SQLSRV_PARAM_IN),

    array($AssessmentID, SQLSRV_PARAM_OUT)

    );

     /* Execute the query. */

     $stmt = sqlsrv_query( $dbconn, $sql, $params);

    echo "Output: " . $AssessmentID . "<br />";

     

    The stored procedure take the parameters and insert the values in table and return newly create AssessmentID.

    This is giving me the following error message:

    Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -15 [code] => -15 [2] => An invalid direction for parameter 1 was specified. SQLSRV_PARAM_IN, SQLSRV_PARAM_OUT, and SQLSRV_PARAM_INOUT are valid values. [message] => An invalid direction for parameter 1 was specified. SQLSRV_PARAM_IN, SQLSRV_PARAM_OUT, and SQLSRV_PARAM_INOUT are valid values. ) )

     

    Any ideal why..

    thanks for your time.

    K

    Friday, May 28, 2010 9:41 AM

Answers

  • Just resolved the problem:

    I have to modify my stored procedure and added the following lines:

    -- SET NOCOUNT ON added to prevent extra result sets from  
        -- interfering with SELECT statements.  
        SET NOCOUNT ON;

    Thanks for you time,

     

    Friday, May 28, 2010 11:28 AM