sql 存储过程

[复制链接]
查看11 | 回复2 | 2009-8-5 09:44:09 | 显示全部楼层 |阅读模式
太明显了,都告诉你了:d附件有语法错误;在你的存储过程中你用/* */来把你不想执行的部分注释掉看看CREATE PROCEDUREver_xiaoshouchuku
--
@anvarchar(200),
@a1nvarchar(200)
--
@b int
AS---declare@c nvarchar(50),----仓库--
@d int-----------出入标志begin tran--set @c=(select cwhcode from rdrecord where id=@b);--set @d=(select brdflag from rdrecord where id=@b);--exec(@a);exec(@a1);/*update currentstock setcurrentstock.iquantity=isnull(currentstock.iquantity,0)-rdrecords.iquantity,preout=preout-rdrecords.iquantityfrom rdrecords where rdrecords.id=@b andcwhcode=@c and rdrecords.cinvcode=currentstock.cinvcode and @d=1update currentstock setcurrentstock.iquantity=isnull(currentstock.iquantity,0)+rdrecords.iquantity,prein=prein-rdrecords.iquantityfrom rdrecords where rdrecords.id=@b andcwhcode=@c and rdrecords.cinvcode=currentstock.cinvcode and @d=0*/IF @@error
0
ROLLBACK TRANSACTION
ELSE commit tranGO
回复

使用道具 举报

千问 | 2009-8-5 09:44:09 | 显示全部楼层
调用怎么那么乱呢?单独执行哪条?
回复

使用道具 举报

千问 | 2009-8-5 09:44:09 | 显示全部楼层
存储过程中多语句执行需要用begin和end界定执行语句。如下修改ALTER PROCEDUREver_xiaoshouchuku
--
@anvarchar(200),
@a1nvarchar(200)
--
@b int
ASBEGIN---declare@c nvarchar(50),----仓库--
@d int-----------出入标志begin tran--set @c=(select cwhcode from rdrecord where id=@b);--set @d=(select brdflag from rdrecord where id=@b);--exec(@a);exec(@a1);--update currentstock setcurrentstock.iquantity=isnull(currentstock.iquantity,0)-rdrecords.iquantity,preout=preout-rdrecords.iquantityfrom rdrecords where rdrecords.id=@b andcwhcode=@c and rdrecords.cinvcode=currentstock.cinvcode and @d=1--update currentstock setcurrentstock.iquantity=isnull(currentstock.iquantity,0)+rdrecords.iquantity,prein=prein-rdrecords.iquantityfrom rdrecords where rdrecords.id=@b andcwhcode=@c and rdrecords.cinvcode=currentstock.cinvcode and @d=0IF @@error
0
ROLLBACK TRANSACTION
ELSE commit tranGOEND
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行