【问题标题】:Getting output parameter from stored procedure从存储过程中获取输出参数
【发布时间】:2012-05-04 11:44:10
【问题描述】:

我试图让存储过程触发并返回输出参数以及结果集。目前我只是得到一个输出参数应该是 balnk 变量的结果集数组。

//initiate function
    $proc = mssql_init('usp_Web_Return_Installer_Details', $msdb); 

    $enrolledScopes = '';

    mssql_bind($proc, '@InstallerID', $_SESSION['user']['Installer_ID'], SQLINT4, false, false, 10);

    mssql_bind($proc, '@EnrolledScopes', &$enrolledScopes, SQLVARCHAR, true, true, 5000); 

    //Execute Procedure 
    $result = mssql_execute($proc); 

    do {
    while ($row = mssql_fetch_assoc($result)){
        $results[] = $row;    
        }
    } while (mssql_next_result($result));

    //Free Memory 
    mssql_free_statement($proc); 

    print_r($result);

【问题讨论】:

    标签: php sql-server stored-procedures


    【解决方案1】:

    您需要为存储过程中的输出参数添加mssql_bind

    mssql_bind($stmt, "@outParam", &$outParam, true)
    

    所以,$outParam 是你的结果。

    【讨论】:

    • 这就是这行应该做的:mssql_bind($proc, '@EnrolledScopes', &$enrolledScopes, SQLVARCHAR, true, true, 5000);
    • 是的。所以,结果应该是$enrolledScopes
    • 是的,这就是我的意思,数组 $result 返回预期的内容,但 $enrolledScopes 是空白的
    • 对不起,我没有从你的代码中看到它:D Please check the php bugs,这可能是问题
    • 我确实看到了,但不知道是否有人知道解决方法。那个bug也很老了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 2017-02-21
    • 2019-02-03
    • 2010-09-16
    • 1970-01-01
    • 2020-11-22
    • 2017-04-05
    相关资源
    最近更新 更多