﻿-- =============================================
-- Author:		Steamware - S.E.L.
-- Create date: 2014.04.16
-- Description:	elimina un record in QL (Full) e in tabelle connesse
-- =============================================
create PROCEDURE [dbo].[stp_QLF_Delete]
(
    @Original_QuoteType CHAR(1) = 'Q',
    @Original_CodQuote	BIGINT = 0,
    @Original_QuoteRev	INT = 0
)
AS

SET XACT_ABORT ON;
BEGIN TRAN

	-- elimino da QuoteFull_Q
	DELETE
	FROM QuoteFull_Q
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev
		
	-- elimino da QuoteFull_S
	DELETE
	FROM QuoteFull_S
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev        

	-- elimino da QuoteWorkExt
	DELETE
	FROM QuoteWorkExt
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteWorkInt
	DELETE
	FROM QuoteWorkInt
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteSimPar
	DELETE
	FROM QuoteSimPar
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteRM
	DELETE
	FROM QuoteRM
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteParam
	DELETE
	FROM QuoteParam
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteOC
	DELETE
	FROM QuoteOC
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

	-- elimino da QuoteList
	DELETE
	FROM QuoteList
    WHERE	QuoteType = @Original_QuoteType
        AND CodQuote = @Original_CodQuote
        AND QuoteRev = @Original_QuoteRev

COMMIT TRAN

RETURN