Error in the execution of the PROCEDURE

Asked

Viewed 12 times

0

Health and Peace for all, This is about the following: Has a tb_register, to study how to populate the table with dates (created with Mysql), with the fields:

cliente_id  Primária    int(11) 
data_inicio     date 
dias_semanas    varchar(50)     

I created a PROCEDURE with the name add dates like this:

BEGIN

DECLARE var_data DATE DECLARE var_dia VARCHAR(50); DECLARE counter INT DEFAULT 0; SET var_data = start_date; SET var_dia = DAYNAME(data_iniciO); WHILE counter < DO INTERVAL INSERT INTO tb_register(start date, weekdays) VALUES (var_data, var_dia) ; SET counter = counter + 1; SET var_data = DATE_ADD(data_iniciO, INTERVAL COUNTER DAY); SET var_dia = DAYNAME(var_data); END WHILE;

END

CALL add dates('2021-01-14',5)

When running I get the error message:

Mysql Messages : #1064 - You have a syntax error in your SQL next to 'CALL addir_dates('2021-01-14',5)' on line 19

I was hoping to populate my tb_register with five dates after 2021-01-14 with the respective weekdays.

Thank you

  • You have not shown the setting of the parameters of the process (CREATE PROCEDURE).

  • You are absolutely right. I have not kept, in my studies, the most important thing that are the "Parameters" when creating Procedure. Sorry! I don’t know if it helps to tell you that in "Edit routine", "Parameters" has: "Direction" = INT "Name" = data_start "Type" = DATE

No answers

Browser other questions tagged

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