大家帮忙看下我写的存储过程为什么编译不了

渣皮人 富力科技 移动客户端工程师  2010-10-24 10:05:55
提示我cusor附近和最底下end附近有语法错误,各位兄弟帮帮忙

create procedure pro_up_paidan(

@lv_tj_date DATETIME

)
as

declare @lv_cCusName nvarchar (100)
declare @lv_cInvName nvarchar (100)
declare @lv_cInvStd nvarchar (100)
declare @lv_iQuantity nvarchar (100)
declare @lv_dDate datetime

begin


cursor Rst for select b.cCusName,d.cInvName,d.cInvStd,c.iQuantity,a.dDate from so_somain a,customer b,SO_SODetails c,inventory d where a.cCusCode =b.ccuscode and a.id=c.id and c.cInvCode=d.cInvCode and a.dDate=@lv_tj_date

open Rst

fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate

while @@fetch_status=0

begin

insert into sc_paidan (cCusName,cInvName,cInvStd,iQuantity,dDate,SC_DATE,SC_XH,SC_BH,SC_JSCS,SC_GY,SC_WEIGHT,SC_YL,WHEN_LOGGIN,WHEN_CANCEL,isSelf)values
(@lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate,'',0,'','','','','',@lv_tj_date,null,0)

fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate

end

close Rst
DEALLOCATE Rst

end
...全文
94 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
songguozhi 2010-10-25
[Quote=引用楼主 xuyide54321 的回复:]
提示我cusor附近和最底下end附近有语法错误,各位兄弟帮帮忙

create procedure pro_up_paidan(

@lv_tj_date DATETIME

)
as

declare @lv_cCusName nvarchar (100)
declare @lv_cInvName nvarchar (100)
declare @lv_cInvStd nv……
[/Quote]
create procedure pro_up_paidan(

@lv_tj_date DATETIME

)
as

declare @lv_cCusName nvarchar (100)
declare @lv_cInvName nvarchar (100)
declare @lv_cInvStd nvarchar (100)
declare @lv_iQuantity nvarchar (100)
declare @lv_dDate datetime

begin


DECLARE Rst cursor for
select b.cCusName,d.cInvName,d.cInvStd,c.iQuantity,a.dDate
from so_somain a,customer b,SO_SODetails c,inventory d
where a.cCusCode =b.ccuscode and a.id=c.id and c.cInvCode=d.cInvCode and a.dDate=@lv_tj_date

open Rst

fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate

while @@fetch_status=0

begin

insert into sc_paidan (cCusName,cInvName,cInvStd,iQuantity,dDate,SC_DATE,SC_XH,SC_BH,SC_JSCS,SC_GY,SC_WEIGHT,SC_YL,WHEN_LOGGIN,WHEN_CANCEL,isSelf)values
(@lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate,'',0,'','','','','',@lv_tj_date,null,0)

fetch next from Rst into @lv_cCusName,@lv_cInvName,@lv_cInvStd,@lv_iQuantity,@lv_dDate

end

close Rst
DEALLOCATE Rst

end
回复
abuying 2010-10-24
cursor定义错误!
--少declare

declare Rst cursor for select b.cCusName,d.cInvName,d.cInvStd,c.iQuantity,a.dDate from so_somain a,customer b,SO_SODetails c,inventory d where a.cCusCode =b.ccuscode and a.id=c.id and c.cInvCode=d.cInvCode and a.dDate=@lv_tj_date
回复
zsh0809 2010-10-24
Declare @Age int
Declare @Name varchar(20)
Declare Cur Cursor For Select Age,Name From T_User
Open Cur
Fetch next From Cur Into @Age,@Name
While @@fetch_status=0
Begin
Update T_User Set [Name]=@Name,Age=@Age
Fetch Next From Cur Into @Age,@Name
End
Close Cur
Deallocate Cur
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2010-10-24 10:05
社区公告
暂无公告