gpt4 book ai didi

mysql - SQL 触发器(IBM Tivoli Netcool Omnibus)

转载 作者:行者123 更新时间:2023-11-30 22:10:44 26 4
gpt4 key购买 nike

我有一个关于综合触发器的问题。如果有任何事件与过滤器匹配,我使用此触发器发送电子邮件。

这是过滤器:

begin

for each row critical in alerts.status where critical.Severity = 5 and
critical.Grade <= 6 and critical.LastOccurrence <= ( getdate() - (60*30) )
begin
execute send_email( critical.Node, critical.Severity, 'test2@npp.local','Netcool Email', critical.Summary, 'WINITMSVR631');
update alerts.status via critical.Identifier set Grade=7;
end;

end

我成功发送了一封带有上述触发器的电子邮件,

我想给那个触发器添加几行,它看起来像这样:

begin

for each row critical in alerts.status where critical.Severity = 5 and
critical.Grade <= 6
if critical.Situation = 'blabla1'
{begin
execute send_email( critical.Node, critical.Severity, 'test2@npp.local','Netcool Email', critical.Summary, 'WINITMSVR631');
update alerts.status via critical.Identifier set Grade=7;
end;}
if critical.Situation = 'blabla2'
{begin
execute send_email2( critical.Node, critical.Severity, 'test2@npp.local', 'Netcool Email', critical.Summary, 'WINITMSVR631');
update alerts.status via critical.Identifier set Grade=7;
end;}

end

但我总是遇到一些错误。老实说,我几乎不知道 sql 编程。

任何建议

谢谢你的帮助

最佳答案

首先 - 我不确定您是否可以在触发代码中使用“{”和“}”。语法更像 if Node = 'SomeNode' then update alerts.status set Grade = 8; end if; - 所以它的 if ... then ...; 结束如果;

我已经修复了您的代码并且它通过了 SQL 验证:

begin

for each row critical in alerts.status where critical.Severity = 5 and
critical.Grade <= 6
begin
if (critical.Node = 'blabla1') then
execute send_email( critical.Node, critical.Severity, 'test2@npp.local','Netcool Email', critical.Summary, 'WINITMSVR631');
update alerts.status via critical.Identifier set Grade=7;
end if;
if (critical.Node = 'blabla2') then
execute send_email( critical.Node, critical.Severity, 'test2@npp.local','Netcool Email', critical.Summary, 'WINITMSVR631');
update alerts.status via critical.Identifier set Grade=7;
end if;
end;
end

关于mysql - SQL 触发器(IBM Tivoli Netcool Omnibus),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40190881/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com