dbTalk Databases Forums  

Problem on IF STATEMENT on TRIGGER with MySql 5.0.33

mailing.database.myodbc mailing.database.myodbc


Discuss Problem on IF STATEMENT on TRIGGER with MySql 5.0.33 in the mailing.database.myodbc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
g-factor
 
Posts: n/a

Default Problem on IF STATEMENT on TRIGGER with MySql 5.0.33 - 11-29-2007 , 06:30 AM






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
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.