-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE procedure [C6Mart].[GESTIONE_SELECT_FTP_DA_INVIARE]
AS
BEGIN
insert into GLOBAL_ERROR (ErrorDescription) values ('ingresso')
	SELECT 
		Rete,
		CodiceFiscale,
		IdReport
		,(NomeFile + '_' + (Case TipoReport when 'D' then 'DW' else TipoReport end)) as NomeFile
		,TipoReport
--	,Case TipoReport when 'D' then 'DW' else TipoReport end
--		,
--		DataGenerazione,
--		DataInvio,
--		FlagInvio,
--		NomeFile
	FROM
		C6Mart.GESTIONE_PDF_FTP
	WHERE
	 FlagInvio = 'N'
	 AND CODICEFISCALE + RETE NOT IN (select cod_fiscale + RETE from c6mart.test_Quality)
insert into GLOBAL_ERROR (ErrorDescription) values ('uscita')
END