SET NOCOUNT ON 在 ubuntu 下不起作用
SET NOCOUNT ON is not working under ubuntu
我正在使用 mssql
服务器和 yii framework
我已经创建了一个 stored-procedure
请看下面的代码。
//Call Store procedure to get data
$sql = "EXECUTE IESReportData @assessmentId=:assessmentId, @queId=:queId,@instanceId=:instanceId";
//set database connection and start the yii query builder to be executed.
$connection = Yii::app()->db;
$command = $connection->createCommand($sql);
$command->bindValue(":assessmentId", $assessmentId);
$command->bindValue(":queId", "");
$command->bindValue(":instanceId", "$instanceId");
$Reportresults = $command->queryAll();
这在 ubuntu
环境下工作正常,但在 windows
环境下会出现以下错误。
Fatal error: Uncaught exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[IMSSP]: The active result for the query contains no fields.
通过一些研发我发现我们需要 SET NOCOUNT ON 所以我更改了下面的语句
$sql = "SET NOCOUNT ON EXECUTE IESReportData @assessmentId=:assessmentId, @queId=:queId,@instanceId=:instanceId";
这在 window
中工作正常,但它在 ubuntu
环境下提供空结果。
请帮助我。
下面是在存储过程中设置 nocount on 的例子
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
-- Add the parameters for the stored procedure here
<@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>,
<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
END`enter code here`
GO
我正在使用 mssql
服务器和 yii framework
我已经创建了一个 stored-procedure
请看下面的代码。
//Call Store procedure to get data
$sql = "EXECUTE IESReportData @assessmentId=:assessmentId, @queId=:queId,@instanceId=:instanceId";
//set database connection and start the yii query builder to be executed.
$connection = Yii::app()->db;
$command = $connection->createCommand($sql);
$command->bindValue(":assessmentId", $assessmentId);
$command->bindValue(":queId", "");
$command->bindValue(":instanceId", "$instanceId");
$Reportresults = $command->queryAll();
这在 ubuntu
环境下工作正常,但在 windows
环境下会出现以下错误。
Fatal error: Uncaught exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[IMSSP]: The active result for the query contains no fields.
通过一些研发我发现我们需要 SET NOCOUNT ON 所以我更改了下面的语句
$sql = "SET NOCOUNT ON EXECUTE IESReportData @assessmentId=:assessmentId, @queId=:queId,@instanceId=:instanceId";
这在 window
中工作正常,但它在 ubuntu
环境下提供空结果。
请帮助我。
下面是在存储过程中设置 nocount on 的例子
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
-- Add the parameters for the stored procedure here
<@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>,
<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
END`enter code here`
GO