DROP PROCEDURE IF EXISTS `stp_deleteOfferTree`;


CREATE PROCEDURE `stp_deleteOfferTree`(
    IN `pOfferID` INT
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT 'Rimozione in unica stored di Righe Offerta e Offerta'
BEGIN
    -- Eliminazione order rows
    DELETE 
    FROM    sales_offer_row 
    WHERE   OfferID = pOfferID;

    -- Eliminazione main order
    DELETE 
    FROM    sales_offer 
    WHERE   OfferID = pOfferID;

    -- Return affected rows
    SELECT ROW_COUNT() AS 'RowsDeleted';
END