【发布时间】:2011-08-29 19:13:57
【问题描述】:
有没有办法在存储过程中使用 sqlsrv_num_rows()?
基本上,当我尝试使用此功能时,我会收到以下错误之一,具体取决于我提供的光标:
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -50 [code] => -50 [2] => This function only works with statements that have static or keyset scrollable cursors. [message] => This function only works with statements that have static or keyset scrollable cursors. ) )
或
Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 16954 [code] => 16954 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor. ) [1] => Array ( [0] => 01S02 [SQLSTATE] => 01S02 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0]Cursor type changed [message] => [Microsoft][SQL Server Native Client 10.0]Cursor type changed ) )
我花了一些时间试图寻找解决此问题的方法,但没有成功。
如何使用 SqlSrv 从存储过程中获取行数?我是否必须手动循环遍历结果和 $count++;我想避免这种情况。或者,有什么方法可以更改实际的存储过程以包含游标?我对游标不是很熟悉,所以我真的不知道这是否是一个解决方案。
提前谢谢你!
【问题讨论】:
标签: php sql-server