1,105,225 Community Members

Where is this syntax error??

Member Avatar
klemme
Posting Whiz
376 posts since Mar 2011
Reputation Points: 3 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey,

I am trying to create this EVENT via phpmyadmin, but I get a syntax error which I cant see:

This is the code for the event:

DELIMITER | 
CREATE 
EVENT delete_cart 
ON SCHEDULE EVERY 5 MINUTES
DO 
BEGIN 
DECLARE cartID INTEGER;

DECLARE cartProductID INTEGER;

DECLARE cartAntal INTEGER;

DECLARE cartStr VARCHAR;

SELECT id, produkt_id, antal, str INTO cartID, cartProductID, cartAntal, cartStr FROM cart WHERE added_date >= added_date +10000 LIMIT 1;

UPDATE products SET stock = stock + cartAntal WHERE produkt_id = cartProductID;

UPDATE sizes SET antal = antal + cartAntal WHERE size = cartStr AND product_id = cartProductID;

DELETE FROM cart WHERE id = cartID;

END | 
DELIMITER;

The error message returned is as follows:

#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 'MINUTES DO BEGIN DECLARE cartID INTEGER; DECLARE cartProductID INTEGER; ' at line 3
Member Avatar
pritaeas
mod_pritaeas
11,301 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,833 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 
Member Avatar
klemme
Posting Whiz
376 posts since Mar 2011
Reputation Points: 3 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
0
 

Yep you are right, thanks :-)

delimiter | CREATE EVENT delete_cart ON SCHEDULE EVERY 5 MINUTE DO BEGIN DECLARE cartID INTEGER( 11 ) ;

DECLARE cartProductID INTEGER( 11 ) ;

DECLARE cartAntal INTEGER( 11 ) ;

DECLARE cartStr VARCHAR( 5 ) ;

SELECT id, produkt_id, antal, str
INTO cartID, cartProductID, cartAntal, cartStr
FROM cart
WHERE added_date >= added_date +10000
LIMIT 1 ;

UPDATE products SET stock = stock + cartAntal WHERE produkt_id = cartProductID;

UPDATE sizes SET antal = antal + cartAntal WHERE size = cartStr AND product_id = cartProductID;

DELETE FROM cart WHERE id = cartID;

END | delimiter;
Question Answered as of 2 Years Ago by pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: