Home > PHP Framework > YII > 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?

藏色散人
Release: 2020-07-21 10:36:02
Original
3977 people have browsed it

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;
Copy after login

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
Copy after login

'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)
Copy after login

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!

Related labels:
yii
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template