chetana bhargav
<bhargav_chetana-/[EMAIL PROTECTED]> wrote:
I have two seperate triggers like,
CREATE TRIGGER cnt1
AFTER INSERT
ON tbl1
WHEN (new.Id =1 and new.priority > 2 )
BEGIN
update cnt set Critical = (SELECT Critical from msgs_cnt where
Id=1) + 1 where Id=1;
end;
CREATE TRIGGER cnt2
AFTER INSERT
ON tbl1
WHEN (new.Id =1 and new.priority < 2 )
BEGIN
update cnt set Normal = (SELECT Normal from cnt where Id=1) + 1
where Id=1;
end;
I am trying to combine these two trigs into one using if..else
condition is it possible.
CREATE TRIGGER cnt1
AFTER INSERT
ON tbl1
WHEN new.Id =1
BEGIN
update cnt set Critical = (SELECT Critical from msgs_cnt where Id=1) +
1 where Id=1 and new.priority > 2;
update cnt set Normal = (SELECT Normal from cnt where Id=1) + 1 where
Id=1 and new.priority < 2;
end;
When i try it its giving me error. I tried the following way
BEGIN
if( new.priority > 2)
update cnt set Critical = (SELECT Critical from msgs_cnt where
Id=1) + 1 where Id=1;
else
update cnt set Normal = (SELECT Normal from cnt where Id=1) + 1
where Id=1;
end;
There is no 'if' statement in SQL.
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------