1

i have a question about omnibus triggers. i used this triggers to send an email if there are any event match the filter.

here is the filter:

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

i successfully sent an email with that triggers above,

i want to add a few lines to that triggers, it would be look like this:

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

but i always get some error with that. honestly i barely know about sql programming.

any advise

thank you for your help

  • Please provide the error-message you get. – Fabian S. Oct 22 '16 at 10:18
  • this is the kind of error i got last night. thank you sir "the objectserver reported the following error: 'Error=Parse failure on line 12 of statement'CHECK STATEMENT' create or replace trigger mail_on critical group default triggers debug false enabled true priority 1 comment \'Send email about critical alerts...', at or near 'syntax error' " – Budi Permana Oct 23 '16 at 06:00

1 Answers1

0

first thing - i'm not sure you can use "{" and "}" in the trigger code. syntax is more like if Node = 'SomeNode' then update alerts.status set Grade = 8; end if; - so its if ... then ...; end if;

i'd fixed your code and it passes SQL validation:

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
fgsfds
  • 1
  • 4