Skip navigation links

MySQL Forums :: Events (Job Scheduler) :: What is wrong with this EVENT?


Advanced Search

What is wrong with this EVENT?
Posted by: Russell Brown ()
Date: April 17, 2012 02:25PM

Hello, im fairly new to MySql and im playing around with events :D
Im having a spot of bother with one im wondering if anyone can point out to me why its not working correctly or at least not the way i expect.

CREATE EVENT newQueue1
ON SCHEDULE EVERY 30 SECOND
DO
BEGIN
DECLARE amount integer;
SET amount = (SELECT amount FROM queue WHERE id=1);
IF amount <= 0 THEN
//Do something else
ELSE
UPDATE queue SET amount=amount-1, total_production_time=total_production_time-30 WHERE id=1;
END IF;
END;

What the above is currently doing is take the amount from 200 to 0 on the first pass when it should take really 1 of every 30 seconds.

What have i done wrong? Any help would be greatly appreciated.

Many thanks in advance



Edited 1 time(s). Last edit at 04/17/2012 02:27PM by Russell Brown.

Options: ReplyQuote


Subject Views Written By Posted
What is wrong with this EVENT? 1515 Russell Brown 04/17/2012 02:25PM
Re: What is wrong with this EVENT? 794 Devart Team 04/28/2012 03:35AM


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.