﻿
-- =============================================
-- Author:		Steamware
-- Create date: 2014.02.23
-- Description:	upelimina tutti i record di un offerta
-- =============================================
CREATE PROCEDURE [dbo].[stp_QuoteFull_delete]
(
	@Original_QuoteType CHAR(1) = 'Q'
	,@Original_CodQuote BIGINT = 0
	,@Original_QuoteRev INT = 0
)
AS

SET XACT_ABORT ON;
BEGIN tran
	-- elimino da QuoteFull
	DELETE
	FROM	QuoteFull_Q
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev

	-- elimino da tab child
	DELETE
	FROM	QuoteWorkExt
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev
		
	DELETE
	FROM	QuoteWorkInt
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev
		
	DELETE
	FROM	QuoteOC
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev
		
	DELETE
	FROM	QuoteParam
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev

	-- elimino le 2 master: RM e list...
	DELETE
	FROM	QuoteRM
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev
		
	DELETE
	FROM	QuoteList
	WHERE	QuoteType = @Original_QuoteType
		AND	CodQuote = @Original_CodQuote
		AND	QuoteRev = @Original_QuoteRev

COMMIT tran

RETURN