MySQL Forums
Forum List  »  Triggers

Simple Trigger
Posted by: Arman Barsamian
Date: May 14, 2012 04:15PM

Hello,

I have a simple triggers that's designed to automatically update information in another table. The issue I have is that I need to execute two statements. I have written it as it appears below. Unfortunately, only the first statement executes.

Any help would be appreciate.

Thanks,

Arman
CREATE
DEFINER=`root`@`localhost`
TRIGGER `meetings`.`invoiceDocStatusInsert`
AFTER INSERT ON `meetings`.`invoices`
FOR EACH ROW
BEGIN
    IF new.docStatus = '1' THEN
        IF new.fk_InvoiceType = '10' THEN
            UPDATE meetingparticipants
            SET TravelCostsReimbursed = '1', Attended = '1'
            WHERE (NEW.fk_Meetingid = idMeetings) and (NEW.fk_Participantid = idParticipants);
        ELSEIF new.docStatus = '2' THEN 
          UPDATE meetings.meetingparticipants
          SET TravelCostsReimbursed = NULL, Attended = '1'
          WHERE (NEW.fk_meetingid = idMeetings) and (New.fk_Participantid = idParticipants);
        END IF;
    END IF;
END$$



Edited 2 time(s). Last edit at 05/14/2012 05:11PM by Peter Brawley.

Options: ReplyQuote


Subject
Views
Written By
Posted
Simple Trigger
1895
May 14, 2012 04:15PM
1264
May 14, 2012 05:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.