﻿CREATE procedure [C6MartPeriodico].[GESTIONE_SCARTI_CRUSCOTTO]
    @codicefiscale as varchar(16),
	@rete as varchar(1),	
	@stato as int,
	@errormessage as varchar(1000) 
AS
BEGIN		
	update C6MartPeriodico.CRUSCOTTO_CONTRATTISEI 
	set elab = @stato  where  codicefiscale = @codicefiscale and  rete = @rete and elab = 3
	IF @@ROWCOUNT <> 0  AND @stato < -1 
		INSERT  INTO [C6MartPeriodico].[CRUSCOTTO_SCARTI_PDFGENERATOR] VALUES (@codicefiscale,@rete,getdate(),@errormessage)
END