Did you remember to switch your SQL delimiter ?
MySQL default delimter for SQL is the semicolon ( ; )
MySQL's stored procedure language also uses the semicolon to delimter statements.
These two rules cannot peacefully coexist.
You can get around this in three steps:
1) Change you default SQL limiter to $$
2) Create the Stored Procedure using END $$ instead of END;
3) Change you default SQL limiter back to ;
Like This:
DELIMITER $$
create trigger updatepricech
after insert on tbl_prices for each row
BEGIN
DECLARE closep INTEGER;
select close into closep from temptable where Ticker = new.Ticker;
update tbl_prices set PriceCh = (Close - closep) where Ticker = new.Ticker
and Trade_date = new.Trade_date;
END $$
DELIMITER ;
Hey, give it a try !!!
anniyan <sriram.s@hcl.in> wrote:
Hi all,
When I am trying to create a trigger I get an error message which I am
unable to comprehend.
create trigger updatepricech
after insert on tbl_prices for each row
BEGIN
DECLARE closep INTEGER;
select close into closep from temptable where Ticker = new.Ticker;
update tbl_prices set PriceCh = (Close - closep) where Ticker = new.Ticker
and Trade_date = new.Trade_date;
end;
I get the error :
#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 ''
at line 4
Here line 4 is the declaration part.
Can you please let me know what could be wrong in this query?
--
View this message in context:
http://www.nabble.com/Problem-creati...html#a12522149
Sent from the MySQL - General mailing list archive at Nabble.com.
--
MySQL General Mailing List
For list archives:
http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=r..._dba@yahoo.com
---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.