﻿

-- =============================================
-- Author:		Steamware
-- Create date: 2013.01.23
-- Description:	elimina record QuoteList
-- =============================================
CREATE PROCEDURE [dbo].[stp_QL_delete]
(
    @QuoteType_orig	CHAR(1) = 'Q',
    @CodQuote_orig	BIGINT	= 0,
    @QuoteRev_orig	INT		= 0
)
AS

SET XACT_ABORT ON;
BEGIN TRAN


    DELETE
    FROM	QuoteFull_Q
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig


    DELETE
    FROM	QuoteFull_S
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteFull_R
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteWorkExt
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteWorkInt
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig
        
    DELETE
    FROM	QuoteOC
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteParam
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteRM
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

    DELETE
    FROM	QuoteList
    WHERE	QuoteType   = @QuoteType_orig
        AND	CodQuote    = @CodQuote_orig
        AND	QuoteRev    = @QuoteRev_orig

COMMIT TRAN


RETURN