How do I while with mysql to autogenerate scripts to populate the database

0

People, my problem is this, I have to populate a database based on an excel table, and for each entry in the variable quantity a new row should be added in the table, so I developed this logic where I am going to populate the data using =CONCATENAR() but the logic does not work and I still get the following error message:

[ERRO na consulta 1] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4
[ERRO na consulta 2] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DECLARE qtd INT' at line 1
[ERRO na consulta 3] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DECLARE valor INT' at line 1
[ERRO na consulta 4] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DECLARE dia DATE' at line 1
[ERRO na consulta 5] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DECLARE hora TIME' at line 1
[ERRO na consulta 6] Unknown system variable 'qtd'
[ERRO na consulta 7] Unknown system variable 'valor'
[ERRO na consulta 8] Unknown system variable 'dia'
[ERRO na consulta 9] Unknown system variable 'hora'
[ERRO na consulta 10] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4
[ERRO na consulta 11] Unknown system variable 'cont'
[ERRO na consulta 12] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END WHILE' at line 1
[ERRO na consulta 13] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line 1

The code is as follows:

CREATE PROCEDURE brindes()
BEGIN

  DECLARE cont INT DEFAULT 0;
  DECLARE qtd INT;
  DECLARE valor INT;
  DECLARE dia DATE;
  DECLARE hora TIME;

  SET qtd = 15 ;
  SET valor = 50 ;
  SET dia = '2018-01-15';
  SET hora = '06:00:00';

  WHILE cont >= qtd DO
    INSERT INTO 'brindes_valores' ('serie', 'rede', 'data', 'hora', 'valor', 'detalhes', 'status')
VALUES
    (NULL, NULL, dia, hora, valor, valor, 1);

    SET cont++;
  END WHILE;
END;

The part of the code where I set the variables to be manipulated by excel, but first I need to make it work ...

    
asked by anonymous 30.01.2018 / 19:43

0 answers