Home  >  Article  >  PHP Framework  >  What should I do if I get an error when calling a stored procedure in Yii?

What should I do if I get an error when calling a stored procedure in Yii?

藏色散人
藏色散人Original
2020-07-21 10:36:023923browse

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.

What should I do if I get an error when calling a stored procedure in Yii?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn