I have the following SP:
MERGE INTO DBO.FM_ALERT t1
USING (select max(timestamp) as ts from DBO.FM_ALERT where active=1 and MJID = IMJID and typeid=itypeid) t2
t1.MJID=IMJID and t1.active=1
WHEN MATCHED THEN
UPDATE SET t1.NEXTTIMESTAMP=TIMESTAMP(CDTWHEN);
INSERT INTO DBO.FM_ALERT (TIMESTAMP, nextTIMESTAMP, MJID,CHID,
LOCALX, LOCALY, MESSAGE, DETAILS, ACTIVE, TYPEID)
VALUES (CDTWHEN, CDTWHEN, IMJID,
CCHID, ILOCALX, ILOCALY, CMESSAGE, CDETAILS, 1, ITYPEID);
There's a number of statements after that, but they all are only executed if WHEN MATCHED is ELSE.
I want them to be always executed, not depending on the outcome of MATCHED.
How? How do I "close" the "WHEN MATCHED THEN" - "ELSE"?
All help is appreciated, thank you.