-- Schema: C6MartPeriodicoImmobiliare
-- Stored Procedure: Insert_Immobiliare_GestioneZIP

-- ==================================================================================
-- Author:		<Ernesto Serfilippi>
-- Create date: <27.02.2019>
-- Description:	<Inserimento riga di Immobiliare_GestioneZIP>
-- ==================================================================================
 
 
CREATE PROCEDURE [C6MartPeriodicoImmobiliare].[Insert_Immobiliare_GestioneZIP]

  @IDZip int,
  @NomeFile varchar(255),
  @DataInvio datetime,
  @FlagInvio varchar(1),
  @NomeCartella varchar(255),
  @IDLottoElaborazione int,
  @DataRiferimento varchar(8),
  
  @Return int OUTPUT

 
/*
SP Parameter Comment 
*/
WITH EXEC AS CALLER 
AS
 
/*
SP Body Comment
*/
 
	BEGIN TRANSACTION
    BEGIN TRY
    	  
    INSERT INTO [C6MartPeriodicoImmobiliare].[Immobiliare_GestioneZIP](
       [IDZip]
      ,[NomeFile]
      ,[DataInvio]
      ,[FlagInvio]
      ,[NomeCartella]
      ,[IDLottoElaborazione]
      ,[DataRiferimento]) 
      
      VALUES (
      @IDZip,
      @NomeFile,
      @DataInvio,
      @FlagInvio,
      @NomeCartella,
      @IDLottoElaborazione,
      @DataRiferimento)
  
      Set @Return=@IdZip;
       
    END TRY
    
	BEGIN CATCH
      IF ERROR_NUMBER()=2601 
      BEGIN
        Set @Return=-2601;
      END
       IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION;
     END CATCH
   
    IF @@TRANCOUNT > 0
      COMMIT TRANSACTION;
