Cursor 使用中的 T-Sql 错误 [英] Error on T-Sql in Cursor use
问题描述
下面是我的商店peocedure的一部分,用于从表的视图中读取数据并对其进行处理,但是有一个错误,我想知道......(在select语句中出现8个参数,光标前出现8个参数但有错误!!!)
in below is part of my store peocedure that used to reading data from a view of a table and processing on it , but that have a error and I want to know that... (in select statement appear 8 parameter and front of cursor appear 8 paramete but have Error!!!)
DECLARE CUR CURSOR FOR
SELECT PkJobDoneDaily_Id
, Fk_ExecCarInOwner
, Fk_ActivityType
, Fk_CostSrc
, Fk_ShiftNum
, Fk_WorkGroup
, DetachNum
TotalTime
FROM dbo. ViewAccJobDoneDaily
WHERE Fk_JobDonePeriod = @Fk_JobDonePeriod and IsOk=1 AND IsDel=0 AND Fk_ActivityType=2
OPEN CUR
FETCH NEXT FROM CUR INTO @Fk_JobDoneDaily,@Fk_ExecCarInOwner,@Fk_ActivityType
,@Fk_CostSrc,@Fk_ShiftNum,@Fk_WorkGroup,@DetachNum,@TotalTime
错误:消息 16924,级别 16,状态 1,第 52 行Cursorfetch:INTO 列表中声明的变量数量必须与所选列的数量匹配.
推荐答案
选择列 DetachNum
和 TotalTime
之间缺少逗号.
There is a comma missing between the select columns DetachNum
and TotalTime
.
备注:也许您还应该检查您的选择列 PkJobDoneDaily_Id 是否与变量 @Fk_JobDoneDaily 具有相同的名称,以避免混淆(名称以 P 与 F 开头).
Remark: Maybe you should check too that your select column PkJobDoneDaily_Id has the same name with the variable @Fk_JobDoneDaily to avoid to be confused (names start with P vs. F).
这篇关于Cursor 使用中的 T-Sql 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!