-- Schema: C6MartPeriodicoImmobiliare
-- Stored Procedure: Update_Immobiliare_GestioneZIP

-- ==================================================================================
-- Author:		<Ernesto Serfilippi>
-- Create date: <27.02.2019>
-- Description:	<Aggiornamento Date Report di Immobiliare_GestioneZIP>
-- ==================================================================================
 
 
CREATE PROCEDURE [C6MartPeriodicoImmobiliare].[Update_Immobiliare_GestioneZIP]
  @IdZip int ,
  @DataInvio datetime,
  @FlagInvio varchar(1), 

  @Return int OUTPUT
  
WITH EXEC AS CALLER
AS
 
/*
SP Body Comment
*/
 
	BEGIN TRANSACTION
    BEGIN TRY		
    	
    		UPDATE [C6MartPeriodicoImmobiliare].[Immobiliare_GestioneZIP]      
    		SET
     				[DataInvio] = @DataInvio,
            [FlagInvio] = @FlagInvio
             
      	WHERE [C6MartPeriodicoImmobiliare].[Immobiliare_GestioneZIP].[IDZip] = @IdZip

    		UPDATE [C6MartPeriodicoImmobiliare].[Immobiliare_GestionePDF]      
    		SET
     				[DataInvio] = @DataInvio,
            [FlagInvio] = @FlagInvio
             
      	WHERE [C6MartPeriodicoImmobiliare].[Immobiliare_GestionePDF].[IDZip] = @IdZip

        Set @Return=1;

    END TRY
    
	BEGIN CATCH
      IF ERROR_NUMBER()=2601 
      BEGIN
        IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION;
        Set @Return=-2601;
        
      END
     END CATCH
   
    IF @@TRANCOUNT > 0
      COMMIT TRANSACTION;
