Problem on IF STATEMENT on TRIGGER with MySql

Reply

Join Date: Nov 2007
Posts: 1
Reputation: ihaveguts is an unknown quantity at this point 
Solved Threads: 0
ihaveguts ihaveguts is offline Offline
Newbie Poster

Problem on IF STATEMENT on TRIGGER with MySql

 
0
  #1
Nov 29th, 2007
Hi Everybody,

i found out that to create a trigger i have to remove the BEGIN and END and it works, but as i put an IF STATEMENT inside like this one:

CREATE TRIGGER status_history_upd AFTER UPDATE ON projects
FOR EACH ROW

IF NEW.project_status != OLD.project_status THEN
INSERT INTO project_status_history
SET status_change_date = NEW.project_edit_date,
project_id = NEW.project_id,
status_id = NEW.project_status;
END IF;

for some reason it gives me back this error:

MySQL said:
#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 'INSERT INTO project_status_history
SET status_change_date = NEW.project_edi' at line 5

I really have to put the IF statement because i need to run the INSERT just in some cases.

Can someone please help?

Thanks

Gabriele
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC