Problems creating an event

0

I'm trying to create an event but I get the error below:

And my query:

CREATE EVENT insert_count
ON SCHEDULE
EVERY 50 SECOND
COMMENT 'bla bla bla bla bla bla.'
DO BEGIN
INSERT INTO teste (nome, conectado, desconectado)
SELECT parceiro.nomeP AS 'Parceiro', 
SUM(di.connectedOr = 'true') AS 'ClientesConectados', 
SUM(di.connectedOr = 'false') AS 'ClientesDesconectados'
FROM vpn AS di
JOIN parceiro
ON parceiro.codParceiro = di.idpartner
WHERE di.comName REGEXP 'skytef-'
GROUP BY di.idpartner
END
    
asked by anonymous 20.10.2016 / 17:25

1 answer

0

As per the documentation on Create Event , I changed your scripts by adding the command Delimiter , because so MySql temporarily ignores ; , to execute the command in a block, something like this. More details refer to Defining Stored Programs .

I hope that helps you.

delimiter |
CREATE EVENT insert_count
    ON SCHEDULE
       EVERY 50 SECOND
    COMMENT 'bla bla bla bla bla bla.'
    DO 
    BEGIN
      INSERT INTO teste (nome, conectado, desconectado)
        SELECT parceiro.nomep AS 'Parceiro'
              ,SUM(di.connectedor = 'true') AS 'ClientesConectados'
              ,SUM(di.connectedor = 'false') AS 'ClientesDesconectados'
          FROM vpn AS di
          JOIN parceiro
            ON parceiro.codparceiro = di.idpartner
         WHERE di.comname regexp 'skytef-'
         GROUP BY di.idpartner;
    END |

delimiter;
    
20.10.2016 / 18:32