yii调用存储过程报错的解决办法:首先查看“MYPROC”语句调用后抛出的异常情况;然后根据信息提示,在存储过程中添加语句为“SET NOCOUNT ON;”即可。
yii调用存储过程报错:
YII:调用MSSQL2005存储过程出现“The active result for the query contains no fields.”
推荐:《yii教程》
在用YII调用MSSQL2005的存储过程时,我需要获取返回值,利用了如下语句调用存储过程“MYPROC”:
DECLARE @return_value int; exec @return_value = MYPROC; select @return_value;
调用后抛出以下异常(用var_dump打印出来):
object(CDbException)[50] public 'errorInfo' => array 0 => string 'IMSSP' (length=5) 1 => int -15 2 => string 'The active result for the query contains no fields.' (length=51) protected 'message' => string
'CDbCommand 无法执行 SQL 语句:
SQLSTATE[IMSSP]: The active result for the query contains no fields.. The SQL statement executed was: DECLARE @return_value int;exec @return_value = MYPROC @ActivityID = :ActivityID ;select @return_value;' (length=257)
根据以下信息提示,我在存储过程中添加了这条语句就正常了:
SET NOCOUNT ON;