473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem on IF STATEMENT on TRIGGER with MySql

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
Nov 29 '07 #1
0 1308

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
3
by: level8 | last post by:
Hi, Everybody, I'm a Hungarian SQL user and I need a little help for SQL Server 7 ! I protect my table against bad data with a trigger. I use ROLLBACK and RAISERROR statement in this trigger....
7
by: Lucio Chiessi | last post by:
Hi for all on this... I'm using MS SQL Server 7.0 SP4 in some customers to store some data from an aplication developed by me. I created an trigger to run on update. When I run an update...
1
by: decoy | last post by:
Hi everyone, I have an Oracle trigger that writes any updates to a specified table to a file on the filesystem (using pl/sql). How can this be done using triggers in mySQL 5+? Thanks in...
2
by: filip.brugge | last post by:
I am breeder of birds. I attempt to make one table BIRDS. It looks like this CREATE TABLE `birds` (`id` int(11) not NULL auto_increment, `father_id` int(11) NULL, `mother_id` int(11) NULL,...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
1
by: Jimbo | last post by:
Im having problems with an after insert trigger... Im trying to join the INSERTED table with other tables to retrieve data....Some of these tables it must link to get data inserted into them at...
10
by: sssk28 | last post by:
i have installed fedora core 6 and i am getting following error: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this...
11
by: Sven Reuter | last post by:
Hallo NG, ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer MySQL-Datenbank erstellt. Doch leider funktioniert das nicht und ich habe auch über google keine Hinweise...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.