We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,442 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Where is this syntax error??

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
2
Contributors
2
Replies
21 Minutes
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
klemme
Posting Whiz
311 posts since Mar 2011
Reputation Points: 18
Solved Threads: 8
Skill Endorsements: 0
pritaeas
Posting Prodigy
Moderator
9,316 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,467
Skill Endorsements: 86

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;
klemme
Posting Whiz
311 posts since Mar 2011
Reputation Points: 18
Solved Threads: 8
Skill Endorsements: 0
Question Answered as of 1 Year Ago by pritaeas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0674 seconds using 2.7MB