CREATE DEFINER=`root`@`localhost` PROCEDURE `update_proces_init_idx_rec__while2`()
BEGIN
	-- G.2--while-2-loop-update-proc_with_groups_id-from-parent
	SET @i = 0;
	SET @loopLomit = 100;
	SET @groupCnt = 1;
	WHILE @i < @loopLomit and @groupCnt > 0 DO
		update `CRM_PROCES_idx_TEMP` as p
			join `CRM_PROCES_idx_TEMP` as pp on (
				pp.`ID_PROCES` = p.`PARENT_ID`
				and pp.`idx_PROCES_WITH_GROUPS_ID` is not null
				and pp.`idx_PROCES_WITH_GROUPS_ID` > 0
			)
			set p.`idx_PROCES_WITH_GROUPS_ID` = pp.`idx_PROCES_WITH_GROUPS_ID`
			where p.`idx_PROCES_WITH_GROUPS_ID` is null
		;
		SET @groupCnt = ROW_COUNT();
		SET @i = @i + 1;
	END WHILE;
END
