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
...全文
134 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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
  • 打赏
  • 举报
回复
出什么错误,语法没问题,这是兼容的

估计出在更新的数据上
极佳SQL数据库修复大师10.0,支持MSSQL 7.0 2000 2005 2008 2008R2 2012 2014 2016 2017 支持各种ERP数据库 金蝶 速达 用友 管家婆等等基于MSSQL数据库。支持数据库无法附加 报错等故障。   支持 各种版本SQL数据库 质疑 置疑 断电损坏。   支持 SQL数据库损坏 无法附加 各种报错问题修复。   支持 SQL数据库 823 824 825页损坏等各类错误修复。   支持 MDF NDF文件修复 支持备份文件修复完美支持各种字符集,支持从MDF文件反删除记录。 支持 SQL数据库各种字段类型 支持压缩表 压缩页 压缩记录恢复 支持 sql数据库系统表报错 系统表不一致 断电非法关机坏道导致的可疑 置疑 数据库挂起等故障 支持 SQL数据库PFS GAM SGAM 页损坏 不是有效的数据库等 不是有效的文件头等恢复 支持 SQL数据库DBCC 无法修复的 数据库数据恢复 支持 SQL数据库被勒索病毒加密的数据恢复。(大多被加密数据库都是非完全加密) 支持 blob,image,xml, 跨页数据以及文本大字段恢复 支持 sql数据库多用户架构,以及NDF 文件组。 支持 保存表 数据 存储过程 触发器 视图 函数等元数据及用户数据 支持 保存为脚本或者直接连到SQL保存到SQL数据库 扫描勒索病毒数据库及 损坏严重的数据库 请选择 标准恢复模式 如果发现有表应该有数据但是标准恢复模式没有扫描到 或表数据乱码 或表记录很少 可以用高级恢复模式尝试。 如果两种恢复模式都看不到本应该有数据的表,可以联系我们进行人工恢复。 www.sql110.com www.sql119.com TEL 13510228421 QQ 1186505712

34,838

社区成员

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

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