前后添加语句分隔符
delimiter //
create procedure add_t_workorder_end()
begin
declare i int default 0;
set i = 0;
start transaction
;
while i < 10000 do
-- insert sql
insert into t_workorder_calculation_end(end_count,time)
SELECT count(1) as end_count,DATE_FORMAT(date_sub('2022-08-14 00:00:00',interval i day),'%Y-%m-%d %H:%i:%s') as time from t_workorder where end_time between date_sub('2022-08-14 00:00:00',interval i day) and date_sub('2022-08-14 23:59:59' , interval i day) and end_time is not null;
set i = i + 1;
if date_sub('2022-08-14 23:59:59',interval i day) < '2022-02-16 23:59:59' then set i = 10000;
end if;
end while;
commit;
end
//
call add_t_workorder_end()
DROP PROCEDURE IF EXISTS add_t_workorder_end