YII:调用MSSQL2005存储过程出现“The active result for the query contains no fields.”

时间:2020-12-29 17:16:51

在用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;