执行存储过程老提示必须声明标量变量!来大森帮我看看
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[TPGL_vote]
(
@camid varchar(20),/*活动概要ID*/
@detailsid varchar(20),/*活动明细ID*/
@uid varchar(20),/*用户ID*/
@cou int output /*0 error 投票结束 1投票成功 2 该用户已经投票该活动 3 投票总数超过可投票数 4*/
)
as
/*定义SQL语句变量*/
Declare @sql nvarchar(4000)
Declare @sumvotes int
Declare @countvotes int
Declare @votes int
Declare @uvotes int
begin
/*事物开始*/
begin
/*查询投票活动状态*/
/*set @sql='select @count=count(*) from emp where id=@id'
exec sp_executesql @sql, N'@count int out,@id varchar(20)', @cou out ,@id
*/
set @sql='select @ret= CAM_STATUS from TPGL_CAMPAIGN where CAM_ID=@camid'
exec sp_executesql @sql, N'@ret int out,@camid varchar(20)', @cou out ,@camid
/*0为结束 1 正在进行*/
if(@cou = 0)
begin
set @cou=0;
return @cou;
end
else
begin
/*判断是否已经投票*/
set @sql='select @count=count(*) from TPGL_CAM_USER_MIDDLE where CAM_ID=@detailsid and UID=@uid'
exec sp_executesql @sql, N'@count int out,@detailsid v