Mistake my PROCEDURE

Asked

Viewed 14 times

0

Health and Peace for all. Please have a table tb_feriados_datas_tipo_procedure, which I am studying. The columns tb_feriados_datas_tipo_procedure has:

feriados_id         int(11) AUTO_INCREMENTO
nomes_feriados      varchar(255)
data_feriado        date
dia_semana_feriado  varchar(255)

I would like the result to populate the data_holiday columns with all dates of the year 2021 with the respective weekday_holiday.

I created the PROCEDURE:

DELIMITER $$
CREATE PROCEDURE adicionar_data_feriado(
        IN data_feriado DATE, 
        IN dia_semana_feriado VARCHAR(255),        
)

BEGIN
DECLARE var_data DATE;
DECLARE var_dia VARCHAR(255);
DECLARE contador INT DEFAULT;
SET var_data = data_feriado;
SET var_dia = DAYNAME(data_feriado);
WHILE contador < intervalo DO
    INSERT INTO tb_feriados_datas_tipo_procedure(data_feriado, dia_semana_feriado)VALUES
(var_data, var_dia);
    SET contador = contador + 1;
    SET var_data = DATA_ADD(data_feriado, INTERVAL contador DAY);
    SET var_dia = DAYNAME(var_data);
    END WHILE;
    
    END;   
    DELIMITER;

Result Error: 1 errors were found during analysis.

Mysql Messages : Documentation

#1064 - Você tem um erro de sintaxe no seu SQL próximo a ')
BEGIN
DECLARE var_data DATE;
DECLARE var_dia VARCHAR(255);
DECLARE conta' na linha 4   
  • What comes to be intervalo? Here: DECLARE contador INT DEFAULT; nothing is missing?

  • DECLARE INT COUNTER DEFAULT; already declared. I checked and found nothing missing. What I didn’t report was that in the last line DELIMITER; there is a red flag showing that there is an error there. I can’t create PROCEDURE.

  • After DEFAULT does not need to be informed a value? You use intervalo undefined.

No answers

Browser other questions tagged

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