Hello I need to mix a case statement with some nested ifs but I'm receiving an error I don't know how to start or end the case statement properly. I shortened the FOR statement for readability
Here is the code:
<tt>
BEGIN
FOR events IN (SELECT EBA_CA_EVENTS.EVENT_NAME, EBA_CA_EVENTS.EVENT_ID,....)
LOOP
if events.TYPE_ID <> (32230291965131516245569156552736940921) AND to_date(SYSDATE) = ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT1)
THEN
DBMS_OUTPUT.put_line ('Criteria fits SEND EMAIL Alert 1');
else
if events.TYPE_ID = (32230291965131516245569156552736940921) and nvl(events.COMPLETED_MAIL_SENT,0) <> ('S')
THEN
DBMS_OUTPUT.put_line ('SEND COMPLETED EMAIL TO TERRY');
UPDATE EBA\_CA\_EVENTS set COMPLETED\_MAIL\_SENT = ('S') where ROW\_KEY=events.ROW\_KEY;
else
if events.TYPE_ID <> (32230291965131516245569156552736940921) AND to_date(SYSDATE) = ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT2)
THEN
DBMS_OUTPUT.put_line ('2nd Criteria fits SEND EMAIL Alert 2');
else
if events.TYPE_ID <> (32230291965131516245569156552736940921) AND to_date(SYSDATE) = ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT3)
THEN
DBMS_OUTPUT.put_line ('3rd Criteria fits SEND EMAIL Alert 3');
end if; -- 4
end if; -- 3
end if; -- 2
end if; -- 1
CASE
WHEN events.EVENT_NOT2 is NULL
THEN
if to_date(SYSDATE) > ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT1) AND nvl(events.ALERT1_SENT, 0) <> ('S')
THEN
DBMS_OUTPUT.put_line (' send email if date past part 1');
UPDATE EBA_CA_EVENTS set ALERT1_SENT = ('S') where ROW_KEY=events.ROW_KEY;
end if;
END
else case
WHEN events.EVENT_NOT2 is NOT NULL
THEN
if to_date(SYSDATE) > ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT1) AND nvl(events.ALERT1_SENT, 0) <> ('S') AND to_date(SYSDATE) < ((to_date(to_char(events.EVENT_DUE_DATE, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - events.EVENT_NOT2)
THEN
DBMS_OUTPUT.put_line ('if date past part 2 with value');
UPDATE EBA_CA_EVENTS set ALERT1_SENT = ('S') where ROW_KEY=events.ROW_KEY;
end if;
END
END LOOP;
END
</tt>
The error is occurring around the end of the case statement -- 
I also tried this removing the "else" before the case and a few other variations I just can't perfect the code though, any help would be appreciated, thanks
BTW I can't use IF.... THEN logic I already tried it and once a particular branch comes true then the else statements are bypassed.