SET SQL DIALECT 3;

SET NAMES ISO8859_1;

/******************************************************************************/
/****                         Replicador                                   ****/
/******************************************************************************/

CREATE GENERATOR GEN_CHANGECODE;
SET GENERATOR GEN_CHANGECODE TO 0;

CREATE TABLE CHANGES (
    CHANGECODE  BIGINT NOT NULL,
    TABLENAME   VARCHAR(32) NOT NULL,
    TABLEKEY    BIGINT NOT NULL,
    OP          CHAR(1) NOT NULL,
    LOC_ID      INTEGER NOT NULL
);


CREATE TABLE REPL_TABLES (
    TABLENAME  VARCHAR(32) NOT NULL,
    LOC_ID     INTEGER NOT NULL
);
ALTER TABLE CHANGES ADD CONSTRAINT PK_CHANGES PRIMARY KEY (CHANGECODE);


CREATE INDEX CHANGES_LOC_ID ON CHANGES (LOC_ID);
CREATE INDEX CHANGES_TABLENAME ON CHANGES (TABLENAME);


SET TERM ^ ;

/* Trigger: INSERT_CHANGES */
CREATE TRIGGER INSERT_CHANGES FOR CHANGES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  NEW.CHANGECODE = GEN_ID( GEN_CHANGECODE, 1 );
END
^
SET TERM ; ^

/******************************************************************************/
/****                         Data for tables                              ****/
/******************************************************************************/

INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('AGENTES_COMISIONES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ALBARANES_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ALBARANES_CLIENTE_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ALBARANES_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ALBARANES_PROVEEDOR_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ALMACENES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('ARTICULOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CATEGORIAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CLIENTES_DATOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CLIENTES_DTOS_PROVEEDORES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CLIENTES_GRUPOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CLIENTES_PROCEDENCIAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('COMISIONES_LIQUIDADAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONFIGURACION', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_APUNTES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_ASIENTOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_BALANCES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_CUENTAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_CUENTAS_ESPECIALES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_EJERCICIOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_EPIGRAFES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONT_SUBCUENTAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONTACTOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONTACTOS_CATEGORIAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONTACTOS_DATOS_BANCO', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('CONTACTOS_DIRECCIONES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('VENDEDORES_DATOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('EMPRESAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('EMPRESAS_CONTACTOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('EMPRESAS_DATOS_BANCO', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('EMPRESAS_TIENDAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('EMPRESAS_USUARIOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FACTURAS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FACTURAS_CLIENTE_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FACTURAS_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FACTURAS_PROVEEDOR_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FAMILIAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FORMAS_PAGO', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('FORMAS_PAGO_PLAZOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('INFORMES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('MOVIMIENTOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PAGOS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PAGOS_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PEDIDOS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PEDIDOS_CLIENTE_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PEDIDOS_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PEDIDOS_PROVEEDOR_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PRESUPUESTOS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PRESUPUESTOS_CLIENTE_DETALLES', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PROVEEDORES_DATOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('PROVEEDORES_GRUPOS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('RECIBOS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('RECIBOS_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('REFERENCIAS', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('REMESAS_CLIENTE', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('REMESAS_PROVEEDOR', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('TIENDA_WEB', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('TIPOS_IVA', 1);
INSERT INTO REPL_TABLES (TABLENAME, LOC_ID) VALUES ('UNIDADES_MEDIDA', 1);

COMMIT WORK;

/******************************************************************************/
/****                         Triggers for tables                          ****/
/******************************************************************************/

SET TERM ^ ;

/* Trigger: AGENTES_COMISIONES_DELETE_REPL */
CREATE TRIGGER AGENTES_COMISIONES_DELETE_REPL FOR AGENTES_COMISIONES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'AGENTES_COMISIONES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='AGENTES_COMISIONES';
  END
END
^


/* Trigger: AGENTES_COMISIONES_INSERT_REPL */
CREATE TRIGGER AGENTES_COMISIONES_INSERT_REPL FOR AGENTES_COMISIONES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'AGENTES_COMISIONES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='AGENTES_COMISIONES';
  END
END
^


/* Trigger: AGENTES_COMISIONES_UPDATE_REPL */
CREATE TRIGGER AGENTES_COMISIONES_UPDATE_REPL FOR AGENTES_COMISIONES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'AGENTES_COMISIONES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='AGENTES_COMISIONES';
  END
END
^


/* Trigger: ALBARANES_CLIENTE_DELETE_REPL */
CREATE TRIGGER ALBARANES_CLIENTE_DELETE_REPL FOR ALBARANES_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ALBARANES_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE';
  END
END
^


/* Trigger: ALBARANES_CLIENTE_INSERT_REPL */
CREATE TRIGGER ALBARANES_CLIENTE_INSERT_REPL FOR ALBARANES_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE';
  END
END
^


/* Trigger: ALBARANES_CLIENTE_UPDATE_REPL */
CREATE TRIGGER ALBARANES_CLIENTE_UPDATE_REPL FOR ALBARANES_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE';
  END
END
^


/* Trigger: ALBARANES_CLI_DET_DELETE_REPL */
CREATE TRIGGER ALBARANES_CLI_DET_DELETE_REPL FOR ALBARANES_CLIENTE_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ALBARANES_CLIENTE_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE_DETALLES';
  END
END
^


/* Trigger: ALBARANES_CLI_DET_INSERT_REPL */
CREATE TRIGGER ALBARANES_CLI_DET_INSERT_REPL FOR ALBARANES_CLIENTE_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_CLIENTE_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE_DETALLES';
  END
END
^


/* Trigger: ALBARANES_CLI_DET_UPDATE_REPL */
CREATE TRIGGER ALBARANES_CLI_DET_UPDATE_REPL FOR ALBARANES_CLIENTE_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_CLIENTE_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_CLIENTE_DETALLES';
  END
END
^


/* Trigger: ALBARANES_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER ALBARANES_PROVEEDOR_DELETE_REPL FOR ALBARANES_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ALBARANES_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR';
  END
END
^


/* Trigger: ALBARANES_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER ALBARANES_PROVEEDOR_INSERT_REPL FOR ALBARANES_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR';
  END
END
^


/* Trigger: ALBARANES_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER ALBARANES_PROVEEDOR_UPDATE_REPL FOR ALBARANES_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR';
  END
END
^


/* Trigger: ALBARANES_PROV_DET_DELETE_REPL */
CREATE TRIGGER ALBARANES_PROV_DET_DELETE_REPL FOR ALBARANES_PROVEEDOR_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ALBARANES_PROVEEDOR_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: ALBARANES_PROV_DET_INSERT_REPL */
CREATE TRIGGER ALBARANES_PROV_DET_INSERT_REPL FOR ALBARANES_PROVEEDOR_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_PROVEEDOR_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: ALBARANES_PROV_DET_UPDATE_REPL */
CREATE TRIGGER ALBARANES_PROV_DET_UPDATE_REPL FOR ALBARANES_PROVEEDOR_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALBARANES_PROVEEDOR_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALBARANES_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: ALMACENES_DELETE_REPL */
CREATE TRIGGER ALMACENES_DELETE_REPL FOR ALMACENES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ALMACENES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALMACENES';
  END
END
^


/* Trigger: ALMACENES_INSERT_REPL */
CREATE TRIGGER ALMACENES_INSERT_REPL FOR ALMACENES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALMACENES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALMACENES';
  END
END
^


/* Trigger: ALMACENES_UPDATE_REPL */
CREATE TRIGGER ALMACENES_UPDATE_REPL FOR ALMACENES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ALMACENES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ALMACENES';
  END
END
^


/* Trigger: ARTICULOS_DELETE_REPL */
CREATE TRIGGER ARTICULOS_DELETE_REPL FOR ARTICULOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'ARTICULOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ARTICULOS';
  END
END
^


/* Trigger: ARTICULOS_INSERT_REPL */
CREATE TRIGGER ARTICULOS_INSERT_REPL FOR ARTICULOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ARTICULOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ARTICULOS';
  END
END
^


/* Trigger: ARTICULOS_UPDATE_REPL */
CREATE TRIGGER ARTICULOS_UPDATE_REPL FOR ARTICULOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'ARTICULOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='ARTICULOS';
  END
END
^


/* Trigger: CATEGORIAS_DELETE_REPL */
CREATE TRIGGER CATEGORIAS_DELETE_REPL FOR CATEGORIAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CATEGORIAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CATEGORIAS';
  END
END
^


/* Trigger: CATEGORIAS_INSERT_REPL */
CREATE TRIGGER CATEGORIAS_INSERT_REPL FOR CATEGORIAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CATEGORIAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CATEGORIAS';
  END
END
^


/* Trigger: CATEGORIAS_UPDATE_REPL */
CREATE TRIGGER CATEGORIAS_UPDATE_REPL FOR CATEGORIAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CATEGORIAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CATEGORIAS';
  END
END
^


/* Trigger: CLIENTES_DATOS_DELETE_REPL */
CREATE TRIGGER CLIENTES_DATOS_DELETE_REPL FOR CLIENTES_DATOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID_CLIENTE,'CLIENTES_DATOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DATOS';
  END
END
^


/* Trigger: CLIENTES_DATOS_INSERT_REPL */
CREATE TRIGGER CLIENTES_DATOS_INSERT_REPL FOR CLIENTES_DATOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_CLIENTE,'CLIENTES_DATOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DATOS';
  END
END
^


/* Trigger: CLIENTES_DATOS_UPDATE_REPL */
CREATE TRIGGER CLIENTES_DATOS_UPDATE_REPL FOR CLIENTES_DATOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_CLIENTE,'CLIENTES_DATOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DATOS';
  END
END
^


/* Trigger: CLIENTES_DTOS_PROV_DELETE_REPL */
CREATE TRIGGER CLIENTES_DTOS_PROV_DELETE_REPL FOR CLIENTES_DTOS_PROVEEDORES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CLIENTES_DTOS_PROVEEDORES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DTOS_PROVEEDORES';
  END
END
^


/* Trigger: CLIENTES_DTOS_PROV_INSERT_REPL */
CREATE TRIGGER CLIENTES_DTOS_PROV_INSERT_REPL FOR CLIENTES_DTOS_PROVEEDORES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_DTOS_PROVEEDORES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DTOS_PROVEEDORES';
  END
END
^


/* Trigger: CLIENTES_DTOS_PROV_UPDATE_REPL */
CREATE TRIGGER CLIENTES_DTOS_PROV_UPDATE_REPL FOR CLIENTES_DTOS_PROVEEDORES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_DTOS_PROVEEDORES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_DTOS_PROVEEDORES';
  END
END
^


/* Trigger: CLIENTES_GRUPOS_DELETE_REPL */
CREATE TRIGGER CLIENTES_GRUPOS_DELETE_REPL FOR CLIENTES_GRUPOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CLIENTES_GRUPOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_GRUPOS';
  END
END
^


/* Trigger: CLIENTES_GRUPOS_INSERT_REPL */
CREATE TRIGGER CLIENTES_GRUPOS_INSERT_REPL FOR CLIENTES_GRUPOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_GRUPOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_GRUPOS';
  END
END
^


/* Trigger: CLIENTES_GRUPOS_UPDATE_REPL */
CREATE TRIGGER CLIENTES_GRUPOS_UPDATE_REPL FOR CLIENTES_GRUPOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_GRUPOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_GRUPOS';
  END
END
^


/* Trigger: CLIENTES_PROCED_DELETE_REPL */
CREATE TRIGGER CLIENTES_PROCED_DELETE_REPL FOR CLIENTES_PROCEDENCIAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CLIENTES_PROCEDENCIAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_PROCEDENCIAS';
  END
END
^


/* Trigger: CLIENTES_PROCED_INSERT_REPL */
CREATE TRIGGER CLIENTES_PROCED_INSERT_REPL FOR CLIENTES_PROCEDENCIAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_PROCEDENCIAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_PROCEDENCIAS';
  END
END
^


/* Trigger: CLIENTES_PROCED_UPDATE_REPL */
CREATE TRIGGER CLIENTES_PROCED_UPDATE_REPL FOR CLIENTES_PROCEDENCIAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CLIENTES_PROCEDENCIAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CLIENTES_PROCEDENCIAS';
  END
END
^


/* Trigger: COMISIONES_LIQUID_DELETE_REPL */
CREATE TRIGGER COMISIONES_LIQUID_DELETE_REPL FOR COMISIONES_LIQUIDADAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'COMISIONES_LIQUIDADAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='COMISIONES_LIQUIDADAS';
  END
END
^


/* Trigger: COMISIONES_LIQUID_INSERT_REPL */
CREATE TRIGGER COMISIONES_LIQUID_INSERT_REPL FOR COMISIONES_LIQUIDADAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'COMISIONES_LIQUIDADAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='COMISIONES_LIQUIDADAS';
  END
END
^


/* Trigger: COMISIONES_LIQUID_UPDATE_REPL */
CREATE TRIGGER COMISIONES_LIQUID_UPDATE_REPL FOR COMISIONES_LIQUIDADAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'COMISIONES_LIQUIDADAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='COMISIONES_LIQUIDADAS';
  END
END
^


/* Trigger: CONFIGURACION_DELETE_REPL */
CREATE TRIGGER CONFIGURACION_DELETE_REPL FOR CONFIGURACION
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONFIGURACION','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONFIGURACION';
  END
END
^


/* Trigger: CONFIGURACION_INSERT_REPL */
CREATE TRIGGER CONFIGURACION_INSERT_REPL FOR CONFIGURACION
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONFIGURACION','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONFIGURACION';
  END
END
^


/* Trigger: CONFIGURACION_UPDATE_REPL */
CREATE TRIGGER CONFIGURACION_UPDATE_REPL FOR CONFIGURACION
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONFIGURACION','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONFIGURACION';
  END
END
^


/* Trigger: CONTACTOS_CAT_DELETE_REPL */
CREATE TRIGGER CONTACTOS_CAT_DELETE_REPL FOR CONTACTOS_CATEGORIAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID_CONTACTO,'CONTACTOS_CATEGORIAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_CATEGORIAS';
  END
END
^


/* Trigger: CONTACTOS_CAT_INSERT_REPL */
CREATE TRIGGER CONTACTOS_CAT_INSERT_REPL FOR CONTACTOS_CATEGORIAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_CONTACTO,'CONTACTOS_CATEGORIAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_CATEGORIAS';
  END
END
^


/* Trigger: CONTACTOS_CAT_UPDATE_REPL */
CREATE TRIGGER CONTACTOS_CAT_UPDATE_REPL FOR CONTACTOS_CATEGORIAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_CONTACTO,'CONTACTOS_CATEGORIAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_CATEGORIAS';
  END
END
^


/* Trigger: CONTACTOS_DAT_BAN_DELETE_REPL */
CREATE TRIGGER CONTACTOS_DAT_BAN_DELETE_REPL FOR CONTACTOS_DATOS_BANCO
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONTACTOS_DATOS_BANCO','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DATOS_BANCO';
  END
END
^


/* Trigger: CONTACTOS_DAT_BAN_INSERT_REPL */
CREATE TRIGGER CONTACTOS_DAT_BAN_INSERT_REPL FOR CONTACTOS_DATOS_BANCO
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS_DATOS_BANCO','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DATOS_BANCO';
  END
END
^


/* Trigger: CONTACTOS_DAT_BAN_UPDATE_REPL */
CREATE TRIGGER CONTACTOS_DAT_BAN_UPDATE_REPL FOR CONTACTOS_DATOS_BANCO
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS_DATOS_BANCO','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DATOS_BANCO';
  END
END
^


/* Trigger: CONTACTOS_DELETE_REPL */
CREATE TRIGGER CONTACTOS_DELETE_REPL FOR CONTACTOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONTACTOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS';
  END
END
^


/* Trigger: CONTACTOS_DIR_DELETE_REPL */
CREATE TRIGGER CONTACTOS_DIR_DELETE_REPL FOR CONTACTOS_DIRECCIONES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONTACTOS_DIRECCIONES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DIRECCIONES';
  END
END
^


/* Trigger: CONTACTOS_DIR_INSERT_REPL */
CREATE TRIGGER CONTACTOS_DIR_INSERT_REPL FOR CONTACTOS_DIRECCIONES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS_DIRECCIONES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DIRECCIONES';
  END
END
^


/* Trigger: CONTACTOS_DIR_UPDATE_REPL */
CREATE TRIGGER CONTACTOS_DIR_UPDATE_REPL FOR CONTACTOS_DIRECCIONES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS_DIRECCIONES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS_DIRECCIONES';
  END
END
^


/* Trigger: CONTACTOS_INSERT_REPL */
CREATE TRIGGER CONTACTOS_INSERT_REPL FOR CONTACTOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS';
  END
END
^


/* Trigger: CONTACTOS_UPDATE_REPL */
CREATE TRIGGER CONTACTOS_UPDATE_REPL FOR CONTACTOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONTACTOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONTACTOS';
  END
END
^


/* Trigger: CONT_APUNTES_DELETE_REPL */
CREATE TRIGGER CONT_APUNTES_DELETE_REPL FOR CONT_APUNTES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_APUNTES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_APUNTES';
  END
END
^


/* Trigger: CONT_APUNTES_INSERT_REPL */
CREATE TRIGGER CONT_APUNTES_INSERT_REPL FOR CONT_APUNTES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_APUNTES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_APUNTES';
  END
END
^


/* Trigger: CONT_APUNTES_UPDATE_REPL */
CREATE TRIGGER CONT_APUNTES_UPDATE_REPL FOR CONT_APUNTES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_APUNTES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_APUNTES';
  END
END
^


/* Trigger: CONT_ASIENTOS_DELETE_REPL */
CREATE TRIGGER CONT_ASIENTOS_DELETE_REPL FOR CONT_ASIENTOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_ASIENTOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_ASIENTOS';
  END
END
^


/* Trigger: CONT_ASIENTOS_INSERT_REPL */
CREATE TRIGGER CONT_ASIENTOS_INSERT_REPL FOR CONT_ASIENTOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_ASIENTOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_ASIENTOS';
  END
END
^


/* Trigger: CONT_ASIENTOS_UPDATE_REPL */
CREATE TRIGGER CONT_ASIENTOS_UPDATE_REPL FOR CONT_ASIENTOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_ASIENTOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_ASIENTOS';
  END
END
^


/* Trigger: CONT_BALANCES_DELETE_REPL */
CREATE TRIGGER CONT_BALANCES_DELETE_REPL FOR CONT_BALANCES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_BALANCES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_BALANCES';
  END
END
^


/* Trigger: CONT_BALANCES_INSERT_REPL */
CREATE TRIGGER CONT_BALANCES_INSERT_REPL FOR CONT_BALANCES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_BALANCES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_BALANCES';
  END
END
^


/* Trigger: CONT_BALANCES_UPDATE_REPL */
CREATE TRIGGER CONT_BALANCES_UPDATE_REPL FOR CONT_BALANCES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_BALANCES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_BALANCES';
  END
END
^


/* Trigger: CONT_CUENTAS_DELETE_REPL */
CREATE TRIGGER CONT_CUENTAS_DELETE_REPL FOR CONT_CUENTAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_CUENTAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS';
  END
END
^


/* Trigger: CONT_CUENTAS_ESP_DELETE_REPL */
CREATE TRIGGER CONT_CUENTAS_ESP_DELETE_REPL FOR CONT_CUENTAS_ESPECIALES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_CUENTAS_ESPECIALES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS_ESPECIALES';
  END
END
^


/* Trigger: CONT_CUENTAS_ESP_INSERT_REPL */
CREATE TRIGGER CONT_CUENTAS_ESP_INSERT_REPL FOR CONT_CUENTAS_ESPECIALES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_CUENTAS_ESPECIALES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS_ESPECIALES';
  END
END
^


/* Trigger: CONT_CUENTAS_ESP_UPDATE_REPL */
CREATE TRIGGER CONT_CUENTAS_ESP_UPDATE_REPL FOR CONT_CUENTAS_ESPECIALES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_CUENTAS_ESPECIALES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS_ESPECIALES';
  END
END
^


/* Trigger: CONT_CUENTAS_INSERT_REPL */
CREATE TRIGGER CONT_CUENTAS_INSERT_REPL FOR CONT_CUENTAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_CUENTAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS';
  END
END
^


/* Trigger: CONT_CUENTAS_UPDATE_REPL */
CREATE TRIGGER CONT_CUENTAS_UPDATE_REPL FOR CONT_CUENTAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_CUENTAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_CUENTAS';
  END
END
^


/* Trigger: CONT_EJERCICIOS_DELETE_REPL */
CREATE TRIGGER CONT_EJERCICIOS_DELETE_REPL FOR CONT_EJERCICIOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_EJERCICIOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EJERCICIOS';
  END
END
^


/* Trigger: CONT_EJERCICIOS_INSERT_REPL */
CREATE TRIGGER CONT_EJERCICIOS_INSERT_REPL FOR CONT_EJERCICIOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_EJERCICIOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EJERCICIOS';
  END
END
^


/* Trigger: CONT_EJERCICIOS_UPDATE_REPL */
CREATE TRIGGER CONT_EJERCICIOS_UPDATE_REPL FOR CONT_EJERCICIOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_EJERCICIOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EJERCICIOS';
  END
END
^


/* Trigger: CONT_EPIGRAFES_DELETE_REPL */
CREATE TRIGGER CONT_EPIGRAFES_DELETE_REPL FOR CONT_EPIGRAFES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_EPIGRAFES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EPIGRAFES';
  END
END
^


/* Trigger: CONT_EPIGRAFES_INSERT_REPL */
CREATE TRIGGER CONT_EPIGRAFES_INSERT_REPL FOR CONT_EPIGRAFES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_EPIGRAFES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EPIGRAFES';
  END
END
^


/* Trigger: CONT_EPIGRAFES_UPDATE_REPL */
CREATE TRIGGER CONT_EPIGRAFES_UPDATE_REPL FOR CONT_EPIGRAFES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_EPIGRAFES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_EPIGRAFES';
  END
END
^


/* Trigger: CONT_SUBCUENTAS_DELETE_REPL */
CREATE TRIGGER CONT_SUBCUENTAS_DELETE_REPL FOR CONT_SUBCUENTAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'CONT_SUBCUENTAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_SUBCUENTAS';
  END
END
^


/* Trigger: CONT_SUBCUENTAS_INSERT_REPL */
CREATE TRIGGER CONT_SUBCUENTAS_INSERT_REPL FOR CONT_SUBCUENTAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_SUBCUENTAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_SUBCUENTAS';
  END
END
^


/* Trigger: CONT_SUBCUENTAS_UPDATE_REPL */
CREATE TRIGGER CONT_SUBCUENTAS_UPDATE_REPL FOR CONT_SUBCUENTAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'CONT_SUBCUENTAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='CONT_SUBCUENTAS';
  END
END
^


/* Trigger: VENDEDORES_DATOS_DELETE_REPL */
CREATE TRIGGER VENDEDORES_DATOS_DELETE_REPL FOR VENDEDORES_DATOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID_VENDEDOR,'VENDEDORES_DATOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='VENDEDORES_DATOS';
  END
END
^


/* Trigger: VENDEDORES_DATOS_INSERT_REPL */
CREATE TRIGGER VENDEDORES_DATOS_INSERT_REPL FOR VENDEDORES_DATOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_VENDEDOR,'VENDEDORES_DATOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='VENDEDORES_DATOS';
  END
END
^


/* Trigger: VENDEDORES_DATOS_UPDATE_REPL */
CREATE TRIGGER VENDEDORES_DATOS_UPDATE_REPL FOR VENDEDORES_DATOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_VENDEDOR,'VENDEDORES_DATOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='VENDEDORES_DATOS';
  END
END
^


/* Trigger: EMPRESAS_CONTACTOS_DELETE_REPL */
CREATE TRIGGER EMPRESAS_CONTACTOS_DELETE_REPL FOR EMPRESAS_CONTACTOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'EMPRESAS_CONTACTOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_CONTACTOS';
  END
END
^


/* Trigger: EMPRESAS_CONTACTOS_INSERT_REPL */
CREATE TRIGGER EMPRESAS_CONTACTOS_INSERT_REPL FOR EMPRESAS_CONTACTOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_CONTACTOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_CONTACTOS';
  END
END
^


/* Trigger: EMPRESAS_CONTACTOS_UPDATE_REPL */
CREATE TRIGGER EMPRESAS_CONTACTOS_UPDATE_REPL FOR EMPRESAS_CONTACTOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_CONTACTOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_CONTACTOS';
  END
END
^


/* Trigger: EMPRESAS_DAT_BAN_DELETE_REPL */
CREATE TRIGGER EMPRESAS_DAT_BAN_DELETE_REPL FOR EMPRESAS_DATOS_BANCO
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'EMPRESAS_DATOS_BANCO','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_DATOS_BANCO';
  END
END
^


/* Trigger: EMPRESAS_DAT_BAN_INSERT_REPL */
CREATE TRIGGER EMPRESAS_DAT_BAN_INSERT_REPL FOR EMPRESAS_DATOS_BANCO
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_DATOS_BANCO','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_DATOS_BANCO';
  END
END
^


/* Trigger: EMPRESAS_DAT_BAN_UPDATE_REPL */
CREATE TRIGGER EMPRESAS_DAT_BAN_UPDATE_REPL FOR EMPRESAS_DATOS_BANCO
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_DATOS_BANCO','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_DATOS_BANCO';
  END
END
^


/* Trigger: EMPRESAS_DELETE_REPL */
CREATE TRIGGER EMPRESAS_DELETE_REPL FOR EMPRESAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'EMPRESAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS';
  END
END
^


/* Trigger: EMPRESAS_INSERT_REPL */
CREATE TRIGGER EMPRESAS_INSERT_REPL FOR EMPRESAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS';
  END
END
^


/* Trigger: EMPRESAS_UPDATE_REPL */
CREATE TRIGGER EMPRESAS_UPDATE_REPL FOR EMPRESAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS';
  END
END
^


/* Trigger: EMPRESAS_USUARIOS_DELETE_REPL */
CREATE TRIGGER EMPRESAS_USUARIOS_DELETE_REPL FOR EMPRESAS_USUARIOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'EMPRESAS_USUARIOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_USUARIOS';
  END
END
^


/* Trigger: EMPRESAS_USUARIOS_INSERT_REPL */
CREATE TRIGGER EMPRESAS_USUARIOS_INSERT_REPL FOR EMPRESAS_USUARIOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_USUARIOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_USUARIOS';
  END
END
^


/* Trigger: EMPRESAS_USUARIOS_UPDATE_REPL */
CREATE TRIGGER EMPRESAS_USUARIOS_UPDATE_REPL FOR EMPRESAS_USUARIOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'EMPRESAS_USUARIOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='EMPRESAS_USUARIOS';
  END
END
^


/* Trigger: FACTURAS_CLIENTE_DELETE_REPL */
CREATE TRIGGER FACTURAS_CLIENTE_DELETE_REPL FOR FACTURAS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FACTURAS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE';
  END
END
^


/* Trigger: FACTURAS_CLIENTE_INSERT_REPL */
CREATE TRIGGER FACTURAS_CLIENTE_INSERT_REPL FOR FACTURAS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE';
  END
END
^


/* Trigger: FACTURAS_CLIENTE_UPDATE_REPL */
CREATE TRIGGER FACTURAS_CLIENTE_UPDATE_REPL FOR FACTURAS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE';
  END
END
^


/* Trigger: FACTURAS_CLI_DET_DELETE_REPL */
CREATE TRIGGER FACTURAS_CLI_DET_DELETE_REPL FOR FACTURAS_CLIENTE_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FACTURAS_CLIENTE_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: FACTURAS_CLI_DET_INSERT_REPL */
CREATE TRIGGER FACTURAS_CLI_DET_INSERT_REPL FOR FACTURAS_CLIENTE_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_CLIENTE_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: FACTURAS_CLI_DET_UPDATE_REPL */
CREATE TRIGGER FACTURAS_CLI_DET_UPDATE_REPL FOR FACTURAS_CLIENTE_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_CLIENTE_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: FACTURAS_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER FACTURAS_PROVEEDOR_DELETE_REPL FOR FACTURAS_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FACTURAS_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR';
  END
END
^


/* Trigger: FACTURAS_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER FACTURAS_PROVEEDOR_INSERT_REPL FOR FACTURAS_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR';
  END
END
^


/* Trigger: FACTURAS_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER FACTURAS_PROVEEDOR_UPDATE_REPL FOR FACTURAS_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR';
  END
END
^


/* Trigger: FACTURAS_PROV_DET_DELETE_REPL */
CREATE TRIGGER FACTURAS_PROV_DET_DELETE_REPL FOR FACTURAS_PROVEEDOR_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FACTURAS_PROVEEDOR_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: FACTURAS_PROV_DET_INSERT_REPL */
CREATE TRIGGER FACTURAS_PROV_DET_INSERT_REPL FOR FACTURAS_PROVEEDOR_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_PROVEEDOR_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: FACTURAS_PROV_DET_UPDATE_REPL */
CREATE TRIGGER FACTURAS_PROV_DET_UPDATE_REPL FOR FACTURAS_PROVEEDOR_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FACTURAS_PROVEEDOR_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FACTURAS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: FAMILIAS_DELETE_REPL */
CREATE TRIGGER FAMILIAS_DELETE_REPL FOR FAMILIAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FAMILIAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FAMILIAS';
  END
END
^


/* Trigger: FAMILIAS_INSERT_REPL */
CREATE TRIGGER FAMILIAS_INSERT_REPL FOR FAMILIAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FAMILIAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FAMILIAS';
  END
END
^


/* Trigger: FAMILIAS_UPDATE_REPL */
CREATE TRIGGER FAMILIAS_UPDATE_REPL FOR FAMILIAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FAMILIAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FAMILIAS';
  END
END
^


/* Trigger: FORMAS_PAGO_DELETE_REPL */
CREATE TRIGGER FORMAS_PAGO_DELETE_REPL FOR FORMAS_PAGO
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FORMAS_PAGO','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO';
  END
END
^


/* Trigger: FORMAS_PAGO_INSERT_REPL */
CREATE TRIGGER FORMAS_PAGO_INSERT_REPL FOR FORMAS_PAGO
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FORMAS_PAGO','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO';
  END
END
^


/* Trigger: FORMAS_PAGO_PLAZOS_DELETE_REPL */
CREATE TRIGGER FORMAS_PAGO_PLAZOS_DELETE_REPL FOR FORMAS_PAGO_PLAZOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'FORMAS_PAGO_PLAZOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO_PLAZOS';
  END
END
^


/* Trigger: FORMAS_PAGO_PLAZOS_INSERT_REPL */
CREATE TRIGGER FORMAS_PAGO_PLAZOS_INSERT_REPL FOR FORMAS_PAGO_PLAZOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FORMAS_PAGO_PLAZOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO_PLAZOS';
  END
END
^


/* Trigger: FORMAS_PAGO_PLAZOS_UPDATE_REPL */
CREATE TRIGGER FORMAS_PAGO_PLAZOS_UPDATE_REPL FOR FORMAS_PAGO_PLAZOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FORMAS_PAGO_PLAZOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO_PLAZOS';
  END
END
^


/* Trigger: FORMAS_PAGO_UPDATE_REPL */
CREATE TRIGGER FORMAS_PAGO_UPDATE_REPL FOR FORMAS_PAGO
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'FORMAS_PAGO','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='FORMAS_PAGO';
  END
END
^


/* Trigger: INFORMES_DELETE_REPL */
CREATE TRIGGER INFORMES_DELETE_REPL FOR INFORMES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'INFORMES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='INFORMES';
  END
END
^


/* Trigger: INFORMES_INSERT_REPL */
CREATE TRIGGER INFORMES_INSERT_REPL FOR INFORMES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'INFORMES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='INFORMES';
  END
END
^


/* Trigger: INFORMES_UPDATE_REPL */
CREATE TRIGGER INFORMES_UPDATE_REPL FOR INFORMES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'INFORMES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='INFORMES';
  END
END
^


/* Trigger: MOVIMIENTOS_DELETE_REPL */
CREATE TRIGGER MOVIMIENTOS_DELETE_REPL FOR MOVIMIENTOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'MOVIMIENTOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='MOVIMIENTOS';
  END
END
^


/* Trigger: MOVIMIENTOS_INSERT_REPL */
CREATE TRIGGER MOVIMIENTOS_INSERT_REPL FOR MOVIMIENTOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'MOVIMIENTOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='MOVIMIENTOS';
  END
END
^


/* Trigger: MOVIMIENTOS_UPDATE_REPL */
CREATE TRIGGER MOVIMIENTOS_UPDATE_REPL FOR MOVIMIENTOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'MOVIMIENTOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='MOVIMIENTOS';
  END
END
^


/* Trigger: PAGOS_CLIENTE_DELETE_REPL */
CREATE TRIGGER PAGOS_CLIENTE_DELETE_REPL FOR PAGOS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PAGOS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_CLIENTE';
  END
END
^


/* Trigger: PAGOS_CLIENTE_INSERT_REPL */
CREATE TRIGGER PAGOS_CLIENTE_INSERT_REPL FOR PAGOS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PAGOS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_CLIENTE';
  END
END
^


/* Trigger: PAGOS_CLIENTE_UPDATE_REPL */
CREATE TRIGGER PAGOS_CLIENTE_UPDATE_REPL FOR PAGOS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PAGOS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_CLIENTE';
  END
END
^


/* Trigger: PAGOS_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER PAGOS_PROVEEDOR_DELETE_REPL FOR PAGOS_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PAGOS_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_PROVEEDOR';
  END
END
^


/* Trigger: PAGOS_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER PAGOS_PROVEEDOR_INSERT_REPL FOR PAGOS_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PAGOS_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_PROVEEDOR';
  END
END
^


/* Trigger: PAGOS_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER PAGOS_PROVEEDOR_UPDATE_REPL FOR PAGOS_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PAGOS_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PAGOS_PROVEEDOR';
  END
END
^


/* Trigger: PEDIDOS_CLIENTE_DELETE_REPL */
CREATE TRIGGER PEDIDOS_CLIENTE_DELETE_REPL FOR PEDIDOS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PEDIDOS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE';
  END
END
^


/* Trigger: PEDIDOS_CLIENTE_INSERT_REPL */
CREATE TRIGGER PEDIDOS_CLIENTE_INSERT_REPL FOR PEDIDOS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE';
  END
END
^


/* Trigger: PEDIDOS_CLIENTE_UPDATE_REPL */
CREATE TRIGGER PEDIDOS_CLIENTE_UPDATE_REPL FOR PEDIDOS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE';
  END
END
^


/* Trigger: PEDIDOS_CLI_DET_DELETE_REPL */
CREATE TRIGGER PEDIDOS_CLI_DET_DELETE_REPL FOR PEDIDOS_CLIENTE_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PEDIDOS_CLIENTE_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PEDIDOS_CLI_DET_INSERT_REPL */
CREATE TRIGGER PEDIDOS_CLI_DET_INSERT_REPL FOR PEDIDOS_CLIENTE_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_CLIENTE_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PEDIDOS_CLI_DET_UPDATE_REPL */
CREATE TRIGGER PEDIDOS_CLI_DET_UPDATE_REPL FOR PEDIDOS_CLIENTE_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_CLIENTE_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PEDIDOS_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER PEDIDOS_PROVEEDOR_DELETE_REPL FOR PEDIDOS_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PEDIDOS_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR';
  END
END
^


/* Trigger: PEDIDOS_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER PEDIDOS_PROVEEDOR_INSERT_REPL FOR PEDIDOS_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR';
  END
END
^


/* Trigger: PEDIDOS_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER PEDIDOS_PROVEEDOR_UPDATE_REPL FOR PEDIDOS_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR';
  END
END
^


/* Trigger: PEDIDOS_PROV_DET_DELETE_REPL */
CREATE TRIGGER PEDIDOS_PROV_DET_DELETE_REPL FOR PEDIDOS_PROVEEDOR_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PEDIDOS_PROVEEDOR_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: PEDIDOS_PROV_DET_INSERT_REPL */
CREATE TRIGGER PEDIDOS_PROV_DET_INSERT_REPL FOR PEDIDOS_PROVEEDOR_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_PROVEEDOR_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: PEDIDOS_PROV_DET_UPDATE_REPL */
CREATE TRIGGER PEDIDOS_PROV_DET_UPDATE_REPL FOR PEDIDOS_PROVEEDOR_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PEDIDOS_PROVEEDOR_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PEDIDOS_PROVEEDOR_DETALLES';
  END
END
^


/* Trigger: PRESUPUESTOS_CLI_DELETE_REPL */
CREATE TRIGGER PRESUPUESTOS_CLI_DELETE_REPL FOR PRESUPUESTOS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PRESUPUESTOS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE';
  END
END
^


/* Trigger: PRESUPUESTOS_CLI_INSERT_REPL */
CREATE TRIGGER PRESUPUESTOS_CLI_INSERT_REPL FOR PRESUPUESTOS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PRESUPUESTOS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE';
  END
END
^


/* Trigger: PRESUPUESTOS_CLI_UPDATE_REPL */
CREATE TRIGGER PRESUPUESTOS_CLI_UPDATE_REPL FOR PRESUPUESTOS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PRESUPUESTOS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE';
  END
END
^


/* Trigger: PRESUP_CLI_DET_DELETE_REPL */
CREATE TRIGGER PRESUP_CLI_DET_DELETE_REPL FOR PRESUPUESTOS_CLIENTE_DETALLES
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PRESUPUESTOS_CLIENTE_DETALLES','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PRESUP_CLI_DET_INSERT_REPL */
CREATE TRIGGER PRESUP_CLI_DET_INSERT_REPL FOR PRESUPUESTOS_CLIENTE_DETALLES
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PRESUPUESTOS_CLIENTE_DETALLES','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PRESUP_CLI_DET_UPDATE_REPL */
CREATE TRIGGER PRESUP_CLI_DET_UPDATE_REPL FOR PRESUPUESTOS_CLIENTE_DETALLES
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PRESUPUESTOS_CLIENTE_DETALLES','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PRESUPUESTOS_CLIENTE_DETALLES';
  END
END
^


/* Trigger: PROVEEDORES_DATOS_DELETE_REPL */
CREATE TRIGGER PROVEEDORES_DATOS_DELETE_REPL FOR PROVEEDORES_DATOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID_PROVEEDOR,'PROVEEDORES_DATOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_DATOS';
  END
END
^


/* Trigger: PROVEEDORES_DATOS_INSERT_REPL */
CREATE TRIGGER PROVEEDORES_DATOS_INSERT_REPL FOR PROVEEDORES_DATOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_PROVEEDOR,'PROVEEDORES_DATOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_DATOS';
  END
END
^


/* Trigger: PROVEEDORES_DATOS_UPDATE_REPL */
CREATE TRIGGER PROVEEDORES_DATOS_UPDATE_REPL FOR PROVEEDORES_DATOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID_PROVEEDOR,'PROVEEDORES_DATOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_DATOS';
  END
END
^


/* Trigger: PROVEEDORES_GRUPOS_DELETE_REPL */
CREATE TRIGGER PROVEEDORES_GRUPOS_DELETE_REPL FOR PROVEEDORES_GRUPOS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'PROVEEDORES_GRUPOS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_GRUPOS';
  END
END
^


/* Trigger: PROVEEDORES_GRUPOS_INSERT_REPL */
CREATE TRIGGER PROVEEDORES_GRUPOS_INSERT_REPL FOR PROVEEDORES_GRUPOS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PROVEEDORES_GRUPOS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_GRUPOS';
  END
END
^


/* Trigger: PROVEEDORES_GRUPOS_UPDATE_REPL */
CREATE TRIGGER PROVEEDORES_GRUPOS_UPDATE_REPL FOR PROVEEDORES_GRUPOS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'PROVEEDORES_GRUPOS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='PROVEEDORES_GRUPOS';
  END
END
^


/* Trigger: RECIBOS_CLIENTE_DELETE_REPL */
CREATE TRIGGER RECIBOS_CLIENTE_DELETE_REPL FOR RECIBOS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'RECIBOS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_CLIENTE';
  END
END
^


/* Trigger: RECIBOS_CLIENTE_INSERT_REPL */
CREATE TRIGGER RECIBOS_CLIENTE_INSERT_REPL FOR RECIBOS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'RECIBOS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_CLIENTE';
  END
END
^


/* Trigger: RECIBOS_CLIENTE_UPDATE_REPL */
CREATE TRIGGER RECIBOS_CLIENTE_UPDATE_REPL FOR RECIBOS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'RECIBOS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_CLIENTE';
  END
END
^


/* Trigger: RECIBOS_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER RECIBOS_PROVEEDOR_DELETE_REPL FOR RECIBOS_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'RECIBOS_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_PROVEEDOR';
  END
END
^


/* Trigger: RECIBOS_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER RECIBOS_PROVEEDOR_INSERT_REPL FOR RECIBOS_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'RECIBOS_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_PROVEEDOR';
  END
END
^


/* Trigger: RECIBOS_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER RECIBOS_PROVEEDOR_UPDATE_REPL FOR RECIBOS_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'RECIBOS_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='RECIBOS_PROVEEDOR';
  END
END
^


/* Trigger: REFERENCIAS_DELETE_REPL */
CREATE TRIGGER REFERENCIAS_DELETE_REPL FOR REFERENCIAS
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'REFERENCIAS','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REFERENCIAS';
  END
END
^


/* Trigger: REFERENCIAS_INSERT_REPL */
CREATE TRIGGER REFERENCIAS_INSERT_REPL FOR REFERENCIAS
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REFERENCIAS','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REFERENCIAS';
  END
END
^


/* Trigger: REFERENCIAS_UPDATE_REPL */
CREATE TRIGGER REFERENCIAS_UPDATE_REPL FOR REFERENCIAS
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REFERENCIAS','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REFERENCIAS';
  END
END
^


/* Trigger: REMESAS_CLIENTE_DELETE_REPL */
CREATE TRIGGER REMESAS_CLIENTE_DELETE_REPL FOR REMESAS_CLIENTE
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'REMESAS_CLIENTE','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_CLIENTE';
  END
END
^


/* Trigger: REMESAS_CLIENTE_INSERT_REPL */
CREATE TRIGGER REMESAS_CLIENTE_INSERT_REPL FOR REMESAS_CLIENTE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REMESAS_CLIENTE','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_CLIENTE';
  END
END
^


/* Trigger: REMESAS_CLIENTE_UPDATE_REPL */
CREATE TRIGGER REMESAS_CLIENTE_UPDATE_REPL FOR REMESAS_CLIENTE
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REMESAS_CLIENTE','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_CLIENTE';
  END
END
^


/* Trigger: REMESAS_PROVEEDOR_DELETE_REPL */
CREATE TRIGGER REMESAS_PROVEEDOR_DELETE_REPL FOR REMESAS_PROVEEDOR
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'REMESAS_PROVEEDOR','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_PROVEEDOR';
  END
END
^


/* Trigger: REMESAS_PROVEEDOR_INSERT_REPL */
CREATE TRIGGER REMESAS_PROVEEDOR_INSERT_REPL FOR REMESAS_PROVEEDOR
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REMESAS_PROVEEDOR','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_PROVEEDOR';
  END
END
^


/* Trigger: REMESAS_PROVEEDOR_UPDATE_REPL */
CREATE TRIGGER REMESAS_PROVEEDOR_UPDATE_REPL FOR REMESAS_PROVEEDOR
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'REMESAS_PROVEEDOR','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='REMESAS_PROVEEDOR';
  END
END
^


/* Trigger: TIENDA_WEB_DELETE_REPL */
CREATE TRIGGER TIENDA_WEB_DELETE_REPL FOR TIENDA_WEB
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'TIENDA_WEB','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIENDA_WEB';
  END
END
^


/* Trigger: TIENDA_WEB_INSERT_REPL */
CREATE TRIGGER TIENDA_WEB_INSERT_REPL FOR TIENDA_WEB
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'TIENDA_WEB','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIENDA_WEB';
  END
END
^


/* Trigger: TIENDA_WEB_UPDATE_REPL */
CREATE TRIGGER TIENDA_WEB_UPDATE_REPL FOR TIENDA_WEB
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'TIENDA_WEB','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIENDA_WEB';
  END
END
^


/* Trigger: TIPOS_IVA_DELETE_REPL */
CREATE TRIGGER TIPOS_IVA_DELETE_REPL FOR TIPOS_IVA
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'TIPOS_IVA','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIPOS_IVA';
  END
END
^


/* Trigger: TIPOS_IVA_INSERT_REPL */
CREATE TRIGGER TIPOS_IVA_INSERT_REPL FOR TIPOS_IVA
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'TIPOS_IVA','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIPOS_IVA';
  END
END
^


/* Trigger: TIPOS_IVA_UPDATE_REPL */
CREATE TRIGGER TIPOS_IVA_UPDATE_REPL FOR TIPOS_IVA
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'TIPOS_IVA','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='TIPOS_IVA';
  END
END
^


/* Trigger: UNIDADES_MEDIDA_DELETE_REPL */
CREATE TRIGGER UNIDADES_MEDIDA_DELETE_REPL FOR UNIDADES_MEDIDA
ACTIVE AFTER DELETE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT OLD.ID,'UNIDADES_MEDIDA','D',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='UNIDADES_MEDIDA';
  END
END
^


/* Trigger: UNIDADES_MEDIDA_INSERT_REPL */
CREATE TRIGGER UNIDADES_MEDIDA_INSERT_REPL FOR UNIDADES_MEDIDA
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'UNIDADES_MEDIDA','I',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='UNIDADES_MEDIDA';
  END
END
^


/* Trigger: UNIDADES_MEDIDA_UPDATE_REPL */
CREATE TRIGGER UNIDADES_MEDIDA_UPDATE_REPL FOR UNIDADES_MEDIDA
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
  IF( USER <> 'REPL' ) THEN
  BEGIN
    INSERT INTO CHANGES(TABLEKEY,TABLENAME,OP,LOC_ID)
      SELECT NEW.ID,'UNIDADES_MEDIDA','U',LOC_ID
      FROM REPL_TABLES WHERE TABLENAME='UNIDADES_MEDIDA';
  END
END
^


SET TERM ; ^
