Last answered:

18 Mar 2022

Posted on:

13 Feb 2022

0

Instead of SYSDATE can I use this?

USE employees;

COMMIT;

DELIMITER $$

CREATE TRIGGER before_hire_date
BEFORE INSERT ON employees
FOR EACH ROW
BEGIN
IF NEW.hire_date > 22-02-13 THEN
SET NEW.hire_date = 22-02-13 ;
END IF;
END $$

DELIMITER ;

Can I run this code without using sysdate and get the same result or does SYSDATE allow the code to run anytime in the future wereas the code I'm using is dependent on the day I tried the exercise and the day I asked you this question you are reading right now? (13/02/2022)

1 answers ( 0 marked as helpful)
Instructor
Posted on:

18 Mar 2022

0

Hi Emmanuel!
Thanks for reaching out.

Yes, your code is dependant on the day, whereas using the SYSDATE() function will guarantee that it will use the current date.

Hope this helps.
Best,
Tsvetelin

Submit an answer