0
DELIMITER $$
DROP TRIGGER IF EXISTS TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE $$


CREATE TRIGGER TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE 


    BEFORE UPDATE ON USERS
    FOR EACH ROW 
    BEGIN
    IF @DISABLE_TRIGGERS IS NULL THEN
        IF  NOT (NEW.MANUALEXPIRATIONDATE <=> OLD.MANUALEXPIRATIONDATE) THEN

            SET NEW.CUSTOMFIELD2 = NEW.MANUALEXPIRATIONDATE;
        IF  NOT(NEW.USEREXPIRYDATE <=> OLD.USEREXPIRYDATE)  THEN

            SET NEW.CUSTOMFIELD3 = NEW.USEREXPIRYDATE;
        END IF;
        END IF;         

    END$$

DELIMITER ;

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 17

1
  • Missing closing the first IF. Commented Nov 10, 2015 at 12:26

1 Answer 1

0
CREATE TRIGGER TRIGGER_BEFORE_USERS_MAUALEXPIRY_USEREXPIRAY_UPDATE     

    BEFORE UPDATE ON USERS
    FOR EACH ROW 
    BEGIN
    IF @DISABLE_TRIGGERS IS NULL THEN
        IF  NOT (NEW.MANUALEXPIRATIONDATE <=> OLD.MANUALEXPIRATIONDATE) THEN    
            SET NEW.CUSTOMFIELD2 = NEW.MANUALEXPIRATIONDATE;
        END IF;
        IF  NOT(NEW.USEREXPIRYDATE <=> OLD.USEREXPIRYDATE)  THEN    
            SET NEW.CUSTOMFIELD3 = NEW.USEREXPIRYDATE;
        END IF;    
    END IF;
END
$$
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you jurgen but i want to compare both the conditions. if i use elseif i wil loose one.
Thank you jurgens i got the answer there is a similar thread for this issue. stackoverflow.com/questions/14847702/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.