I am new with mysql triggers, I have 2 tables in a database, one is called tasks
and the other is task_rules
.
Once a new task_rule
is inserted, I want to compare the field time (which is a time object) to the current time.
if it is greater than the current time, I want to add a new row in tasks
and set rid (in tasks
) to id
of the newly added rule, and the time field
in tasks
to the time field
of the newly added row.
I am getting many syntax errors and i didnt know how to create this trigger.
BEGIN
DECLARE @time TIME
DECLARE @freq VARCHAR(400)
@time = NEW.time
@freq = NEW.frequency
IF (@time > NOW()) AND (@freq == 'daily') THEN
INSERT INTO task_rules ('rid', 'time') VALUES (NEW.id, @time)
END IF
END
Im doing it using phpmyadmin