CREATE OR REPLACE
PROCEDURE ITEMCOLE_ATU_CUSTOSUP
  (P_CDFILIAL     IN ITEMCOLE.CDFILIAL%TYPE,
   P_NRCOLEPRECO  IN ITEMCOLE.NRCOLEPRECO%TYPE,
   P_CDMARCA      IN ITEMCOLE.CDMARCA%TYPE,
   P_CDREGIAO     IN ITEMCOLE.CDREGIAO%TYPE,
   P_CDFORNECED   IN ITEMCOLE.CDFORNECED%TYPE,
   P_CDPRODUTO    IN ITEMCOLE.CDPRODUTO%TYPE,
   P_NRSEQPRELIST IN ITEMCOLE.NRSEQPRELIST%TYPE) IS

BEGIN
   FOR C_ITEM IN (SELECT CDFILIAL, CDPRODUTO ,CDFILCOTLIST, NRCOLEPRLIST,
                         CDMARCALIST, CDREGIAOLIST, CDFORNECLIST, CDPRODLIST
                    FROM CUSTOSUP
                   WHERE CDFILCOTLIST  = P_CDFILIAL
                     AND NRCOLEPRLIST  = P_NRCOLEPRECO
                     AND CDMARCALIST   = P_CDMARCA
                     AND CDREGIAOLIST  = P_CDREGIAO
                     AND CDFORNECLIST  = P_CDFORNECED
                     AND CDPRODLIST    = P_CDPRODUTO)
   LOOP
      DELETE
        FROM CUSTOSUP
       WHERE CDFILIAL      = C_ITEM.CDFILIAL
         AND CDFILCOTLIST  = P_CDFILIAL
         AND NRCOLEPRLIST  = P_NRCOLEPRECO
         AND CDMARCALIST   = P_CDMARCA
         AND CDREGIAOLIST  = P_CDREGIAO
         AND CDFORNECLIST  = P_CDFORNECED
         AND CDPRODLIST    = P_CDPRODUTO;
      LISPREC_UPPRODFILI(P_CDFILIAL, P_NRSEQPRELIST, 'N', C_ITEM.CDFILIAL, C_ITEM.CDREGIAOLIST, C_ITEM.CDPRODUTO);
   END LOOP;
   FOR C_ITEM_ACOR IN (SELECT CDFILIAL, CDPRODUTO, CDFILCOTACOR, NRCOLEPRACOR,
                              CDMARCAACOR, CDREGIAOACOR, CDFORNECACOR, CDPRODACOR
                         FROM CUSTOSUP
                        WHERE CDFILCOTACOR  = P_CDFILIAL
                          AND NRCOLEPRACOR  = P_NRCOLEPRECO
                          AND CDMARCAACOR   = P_CDMARCA
                          AND CDREGIAOACOR  = P_CDREGIAO
                          AND CDFORNECACOR  = P_CDFORNECED
                          AND CDPRODACOR    = P_CDPRODUTO)
   LOOP
      DELETE
        FROM CUSTOSUP
       WHERE CDFILIAL      = C_ITEM_ACOR.CDFILIAL
         AND CDFILCOTACOR  = P_CDFILIAL
         AND NRCOLEPRACOR  = P_NRCOLEPRECO
         AND CDMARCAACOR   = P_CDMARCA
         AND CDREGIAOACOR  = P_CDREGIAO
         AND CDFORNECACOR  = P_CDFORNECED
         AND CDPRODACOR    = P_CDPRODUTO;
      LISPREC_UPPRODFILI(P_CDFILIAL, P_NRSEQPRELIST, 'N', C_ITEM_ACOR.CDFILIAL, C_ITEM_ACOR.CDREGIAOACOR, C_ITEM_ACOR.CDPRODACOR);
   END LOOP;
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('ITEMCOLE_ATU_CUSTOSUP','6.05.xxx'); END;
/
