0

I've never done this before, but why do I keep getting and error when I try to create this event. I'm using HeidiSql to do this. Also, can LOOPS, WHILE, IF ELSE be used in events?

BEGIN

DECLARE x TIMESTAMP;
DECLARE y INT;
DECLARE a VARCHAR(50); // Here's where the error is.

SET x = current_timestamp();
insert into checked (stamp) values (x);

SELECT count(stamp) INTO y FROM checked;
        IF y > 10 THEN// It also throws an error here.
            a = 'PASS';
            else
            a = 'FAIL';
        END IF;  

insert into checked (timeCount) values (a);

END
Norman
  • 6,159
  • 23
  • 88
  • 141
  • please specified your exact problem. – Deniyal Tandel May 09 '13 at 09:51
  • @Daniel I'm creating an event. I get /* SQL 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 '= 'PASS'; else a = 'FAIL'; END IF; inser' at line 17 */ – Norman May 09 '13 at 09:53

2 Answers2

3

Use

SET  a = 'PASS'; 

instead of

a = 'PASS';

Every where you assign value.

Deniyal Tandel
  • 512
  • 3
  • 14
  • Thanks for helping. Like I said I'm doing an even the first time. I was following this: http://stackoverflow.com/questions/7031469/how-to-properly-loop-in-a-stored-function-on-mysql – Norman May 09 '13 at 10:03
0

Use "DELIMITER" to execute entire block in mysql

such as.....

DELIMITER

//Your code 

DELIMITER;
Deniyal Tandel
  • 512
  • 3
  • 14