MySQL Forums
Forum List  »  Triggers

create trigger before insert
Posted by: Kent Weyers
Date: September 11, 2007 05:53AM

Hi All,

I'm trying to create a before insert triger, I'm running MySQl 5

DELIMITER $$

DROP TRIGGER `jasprint`.`Callpercchargerate`$$

CREATE TRIGGER `jasprint`.`Callpercchargerate` BEFORE INSERT on `jasprint`.`jobs`
DECLARE Callpercchargerate FLOAT;
FOR EACH ROW BEGIN
if jobs.duration between 120 and 900 then set jobs.Callpercchargerate =0.50
else if jobs.duration between 901 and 1800 then set jobs.Callpercchargerate =0.50
else if jobs.duration between 1801 and 2700 then set jobs.Callpercchargerate = 0.75
else if jobs.duration between 2701 and 3600 then set jobs.Callpercchargerate = 1.0
END$$

DELIMITER ;

and I get the following errors on it

Error Code : 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 'DECLARE Callpercchargerate FLOAT;
FOR EACH ROW BEGIN
if jobs.duration between ' at line 2
(0 ms taken)

if some one could please help it would be greately appreciated,

Options: ReplyQuote


Subject
Views
Written By
Posted
create trigger before insert
2367
September 11, 2007 05:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.