User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,177 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,597 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 1086 | Replies: 0
Reply
Join Date: Nov 2007
Posts: 1
Reputation: ihaveguts is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ihaveguts ihaveguts is offline Offline
Newbie Poster

Problem on IF STATEMENT on TRIGGER with MySql

  #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
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Other Threads in the MySQL Forum

All times are GMT -4. The time now is 7:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC