The solution to the error when yii calls the stored procedure: first check the exceptions thrown after the "MYPROC" statement is called; then according to the information prompt, add the statement "SET NOCOUNT ON;" to the stored procedure.
yii reports an error when calling a stored procedure:
YII: "The active result for the query appears when calling a MSSQL2005 stored procedure contains no fields."
Recommendation: "yii tutorial"
When calling the stored procedure of MSSQL2005 with YII, I need to get the return value and use the following statement to call Stored procedure "MYPROC":
DECLARE @return_value int; exec @return_value = MYPROC; select @return_value;
The following exception is thrown after being called (printed out with 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 cannot execute the SQL statement:
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)
According to the following information Tip, I added this statement to the stored procedure and it became normal:
SET NOCOUNT ON;
The above is the detailed content of What should I do if I get an error when calling a stored procedure in Yii?. For more information, please follow other related articles on the PHP Chinese website!