Sei sulla pagina 1di 3

trigger para auditoria SET TERM ^ ; CREATE TRIGGER IBE$CONTAS_RECEBER_AU FOR CONTAS_RECEBER ACTIVE AFTER UPDATE POSITION 32767

as declare variable tid integer; begin tid = gen_id(ibe$log_tables_gen,1); insert into ibe$log_tables (id, table_name, operation, date_time, user_name) values (:tid, 'CONTAS_RECEBER', 'U', 'NOW', user); if ((old.numero_documento is null and new.numero_documento is not null) or (new.numero_documento is null and old.numero_documento is not null) or (new.numero_documento is not null and old.numero_documento is not null and new.numero_documento <> old.numero_documento)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'NUMERO_DOCUMENTO', old.numero_documento, new.numero_documento); if ((old.conta_contabil is null and new.conta_contabil is not null) or (new.conta_contabil is null and old.conta_contabil is not null) or (new.conta_contabil is not null and old.conta_contabil is not null and new.conta_contabil <> old.conta_contabil)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'CONTA_CONTABIL', old.conta_contabil, new.conta_contabil); if ((old.dtemissao is null and new.dtemissao is not null) or (new.dtemissao is null and old.dtemissao is not null) or (new.dtemissao is not null and old.dtemissao is not null and new.dtemissao <> old.dtemissao)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'DTEMISSAO', old.dtemissao, new.dtemissao); if ((old.dtvencimento is null and new.dtvencimento is not null) or (new.dtvencimento is null and old.dtvencimento is not null) or (new.dtvencimento is not null and old.dtvencimento is not null and new.dtvencimento <> old.dtvencimento)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'DTVENCIMENTO', old.dtvencimento, new.dtvencimento); if ((old.valor_da_parcela is null and new.valor_da_parcela is not null) or (new.valor_da_parcela is null and old.valor_da_parcela is not null) or (new.valor_da_parcela is not null and old.valor_da_parcela is not null and new.valor_da_parcela <> old.valor_da_parcela)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_DA_PARCELA', old.valor_da_parcela, new.valor_da_parcela);

if ((old.valor_pago is null and new.valor_pago is not null) or (new.valor_pago is null and old.valor_pago is not null) or (new.valor_pago is not null and old.valor_pago is not null and new.valor_pago <> old.valor_pago)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_PAGO', old.valor_pago, new.valor_pago); if ((old.valor_duplicata is null and new.valor_duplicata is not null) or (new.valor_duplicata is null and old.valor_duplicata is not null) or (new.valor_duplicata is not null and old.valor_duplicata is not null and new.valor_duplicata <> old.valor_duplicata)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_DUPLICATA', old.valor_duplicata, new.valor_duplicata); if ((old.valor_juros is null and new.valor_juros is not null) or (new.valor_juros is null and old.valor_juros is not null) or (new.valor_juros is not null and old.valor_juros is not null and new.valor_juros <> old.valor_juros)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_JUROS', old.valor_juros, new.valor_juros); if ((old.valor_mora is null and new.valor_mora is not null) or (new.valor_mora is null and old.valor_mora is not null) or (new.valor_mora is not null and old.valor_mora is not null and new.valor_mora <> old.valor_mora)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_MORA', old.valor_mora, new.valor_mora); if ((old.valor_desconto is null and new.valor_desconto is not null) or (new.valor_desconto is null and old.valor_desconto is not null) or (new.valor_desconto is not null and old.valor_desconto is not null and new.valor_desconto <> old.valor_desconto)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_DESCONTO', old.valor_desconto, new.valor_desconto); if ((old.datapgto is null and new.datapgto is not null) or (new.datapgto is null and old.datapgto is not null) or (new.datapgto is not null and old.datapgto is not null and new.datapgto <> old.datapgto)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'DATAPGTO', old.datapgto, new.datapgto); if ((old.valor_pago_int_parc is null and new.valor_pago_int_parc is not null) or (new.valor_pago_int_parc is null and old.valor_pago_int_parc is not null) or (new.valor_pago_int_parc is not null and old.valor_pago_int_parc is not null and new.valor_pago_int_parc <> old.valor_pago_int_parc)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'VALOR_PAGO_INT_PARC', old.valor_pago_int_parc,

new.valor_pago_int_parc); if ((old.descontos is null and new.descontos is not null) or (new.descontos is null and old.descontos is not null) or (new.descontos is not null and old.descontos is not null and new.descontos <> old.descontos)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'DESCONTOS', old.descontos, new.descontos); if ((old.juros_multas is null and new.juros_multas is not null) or (new.juros_multas is null and old.juros_multas is not null) or (new.juros_multas is not null and old.juros_multas is not null and new.juros_multas <> old.juros_multas)) then insert into ibe$log_fields (log_tables_id, field_name, old_value, new_value) values (:tid, 'JUROS_MULTAS', old.juros_multas, new.juros_multas); end; ^

Potrebbero piacerti anche