CREATE OR REPLACE PROCEDURE sp_fdt_rea_aum_emb_ns
(
    pch_compania      char,
    psi_id_calendario number
)
/*********************************************************************/
/*** Modulo:      Módulo Fiscal Colombiano - Embargos              ***/
/*** Descripcion: aumenta cuota fija de embargos                   ***/
/*** Autor:	  Laura A. Guzman M                                    ***/
/*** Fecha:	  Junio 29 de 2006                                     ***/
/*** Motor:	  SQL Server 2000	Version interna: 1.00              ***/
/*********************************************************************/
AS
BEGIN
    UPDATE
        fdt_embargos
    SET
        cuota_fija = 
        (SELECT cuota_anterior FROM fdt_hist_aum_emb a
         WHERE a.compania = fdt_embargos.compania And
          a.trabajador = fdt_embargos.trabajador And
          a.concepto = fdt_embargos.concepto And
          a.secuencia = fdt_embargos.secuencia And
          a.id_calendario = psi_id_calendario)
    WHERE 
        compania = pch_compania And
        EXISTS (SELECT 1 FROM fdt_hist_aum_emb a
         WHERE a.compania = fdt_embargos.compania And
          a.trabajador = fdt_embargos.trabajador And
          a.concepto = fdt_embargos.concepto And
          a.secuencia = fdt_embargos.secuencia And
          a.id_calendario = psi_id_calendario);

    DELETE
        fdt_hist_aum_emb
    WHERE
        compania = pch_compania And
        id_calendario = psi_id_calendario;
    

    COMMIT;
END;
/
CREATE PUBLIC SYNONYM sp_fdt_rea_aum_emb_ns  FOR ADAM.sp_fdt_rea_aum_emb_ns;
GRANT EXECUTE ON sp_fdt_rea_aum_emb_ns TO ADAMA;
