DELIMITER $$
CREATE PROCEDURE standard_sku_history()
begin
DECLARE $total int;
DECLARE $current int;
DECLARE $third_platform_sku_id varchar(100);
DECLARE $cost_price decimal(20,2);
set $current = 0;
select count(1) into $total from `sbc-goods`.`standard_sku` where third_platform_sku_id is not null and cost_price is not null and third_goods_source = 0;
while $current < $total do
select third_platform_sku_id into $third_platform_sku_id from `sbc-goods`.`standard_sku` where third_platform_sku_id is not null and cost_price is not null and third_goods_source = 0 limit $current,1;
select cost_price into $cost_price from `sbc-goods`.`standard_sku` where third_platform_sku_id is not null and cost_price is not null and third_goods_source = 0 limit $current,1;
INSERT INTO `sbc-goods`.standard_sku_history_cost_price (third_platform_sku_id, cost_price, create_time, update_time) VALUES ($third_platform_sku_id, $cost_price, '2022-08-23 16:49:00', '2022-08-23 16:49:00');
set $current = $current + 1;
end while ;
END$$
DELIMITER ;
call standard_sku_history()