Problems when creating an event

Asked

Viewed 35 times

0

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

inserir a descrição da imagem aqui

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

1 answer

0

As documentation on Create Event, I changed your scripts by adding the command Delimiter, because this way Mysql ignores the ;, to execute the command in a block, something like that. More details see Defining Stored Programs.

I hope it 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;
  • 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 'delimiter' at line 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.