sql 2008 写的触发器 在 sql 2000中运行总是报错?客户现场求解答啊

xch2125535 2011-12-04 03:09:41
alter TRIGGER NFD_2
ON t_BOS200000000
for update
AS
begin
SET NOCOUNT ON

declare @fcheckstatus int
select @fcheckstatus=fmulticheckstatus from inserted
if (@fcheckstatus=16)

begin
update PORequestEntry set fauxqty=t4.fqtynow from PORequestEntry as t1 --采购申请
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid
end

begin
update ICSMInquiryMtrlEntry set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid
end

begin
update ICSMQuotationEntry set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid
end

begin
update t_rpContractEntry set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid
end

begin
update POOrderEntry set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end


if (@fcheckstatus=4)

begin
update PORequestEntry set fauxqty=t4.FDecimal from PORequestEntry as t1
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid
end

begin
update ICSMInquiryMtrlEntry set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid
end

begin
update ICSMQuotationEntry set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid
end

begin
update t_rpContractEntry set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid
end

begin
update POOrderEntry set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end

end
...全文
130 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
唐诗三百首 2011-12-04
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xch2125535 的回复:]
提示 SET NOCOUNT ON

附近有语法错误
[/Quote]
把"SET NOCOUNT ON"去掉试试,对程序逻辑不影响的.
xch2125535 2011-12-04
  • 打赏
  • 举报
回复
谢谢 各位 问题出在了 --采购申请

“--”
这个的注释上面。。我疯了
xch2125535 2011-12-04
  • 打赏
  • 举报
回复
提示 SET NOCOUNT ON

附近有语法错误
xch2125535 2011-12-04
  • 打赏
  • 举报
回复
to qianjin036a
这个开始方法试过了 也不行

-晴天 2011-12-04
  • 打赏
  • 举报
回复
不知道你的业务流程,试试这样:
alter TRIGGER NFD_2  
ON t_BOS200000000
for update
AS
begin
SET NOCOUNT ON

declare @fcheckstatus int
select @fcheckstatus=fmulticheckstatus from inserted
if (@fcheckstatus=16)

begin
update t1 set fauxqty=t4.fqtynow from PORequestEntry as t1 --采购申请
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid

update t1 set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid

update t1 set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid

update t1 set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid

update t1 set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end


if (@fcheckstatus=4)

begin
update t1 set fauxqty=t4.FDecimal from PORequestEntry as t1
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid

update t1 set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid

update t1 set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid

update t1 set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid

update t12 set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end

end
geniuswjt 2011-12-04
  • 打赏
  • 举报
回复
没看出错,不过写这触发器的人不适合做软件行业
-晴天 2011-12-04
  • 打赏
  • 举报
回复
程序写得好奇怪,写那么多begin end 干嘛?还有那个if,如果不用else 下面的更新语句都是重复的.
pengxuan 2011-12-04
  • 打赏
  • 举报
回复
什么错误呢
--小F-- 2011-12-04
  • 打赏
  • 举报
回复
报什么错误 ?语法没什么问题啊。
唐诗三百首 2011-12-04
  • 打赏
  • 举报
回复
要看一下详细的错误信息..
中国风 2011-12-04
  • 打赏
  • 举报
回复
出什么错误,语法没问题,这是兼容的

估计出在更新的数据上

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧