wood burning stoves 2.0*
The moose likes JDBC and the fly likes how to use triggers on mysql - query produce error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to use triggers on mysql - query produce error " Watch "how to use triggers on mysql - query produce error " New topic
Author

how to use triggers on mysql - query produce error

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi there,

Can anyone advise why this sql statement is incorrect?
I'm trying to learn how to use triggers on mysql



I get:
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 'where car_id='6723' )
THEN
UPDATE cars set car_n

* using mysql version: 5.0.45-community-nt
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
I have no idea why you'd want to use a trigger for something this specific... but something more like this:

CREATE TRIGGER T1
AFTER UPDATE ON cars
FOR EACH ROW
BEGIN
IF (fax_number='555555' and car_id='6723') THEN
set car_name = 'test';
END IF;
END;

If the columns you are testing for are being updated... you will new to use NEW/OLD depending on your test state.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use triggers on mysql - query produce error