drop procedure if exists public.sp_DeleteFrllo;
drop procedure if exists dbo.sp_DeleteFrllo;
-- =============================================
-- Author:      Vitacore (с) Anatoliy
-- Create date: 2021 02 17
-- Description: Удаление данных ФРЛЛО
-- =============================================
create or replace procedure rds.sp_DeleteFrllo
(
	"Id" uuid default null::uuid
)
language plpgsql
as
$$
begin
	loop
		if exists(select 1 from  RDS.T_EXPORT_FRLLO_DATA where ExportFrllo = "Id" limit 1)
			delete top(10000) from RDS.T_EXPORT_FRLLO_DATA where ExportFrllo = "Id";
		end if;
	end loop;
	
	loop
		if exists(select 1 from  RDS.T_EXPORT_FRLLO where ExportFrlloID = "Id" limit 1)
			delete top(10000) from RDS.T_EXPORT_FRLLO where ExportFrlloID = "Id";
		end if;
	end loop;
end;
$$;