Subject Re: [firebird-support] Re: execute statement
Author Alexandre Benson Smith
Em 9/8/2012 17:19, Mark Rotteveel escreveu:
> I think you need to create an EXECUTE BLOCK statement as text and then
> execute that using EXECUTE STATEMENT, however I am not actually sure if
> that would give you access to the NEW and OLD context tables.
> Mark

There is no way to access NEW and OLD context variables inside EXECUTE

To achieve what he wants he will need to write an app (or stored
procedure, or whatever) that loops trough the fields and generate the
trigger PSQL code like

CREATE OR ALTER trigger tlm_maestro_au0 for tlm_maestro
active after update position 0 AS
declare variable loc_nuevo_id id;
declare variable loc_ejecutar descripcion_larga;

loc_nuevo_id = gen_id(gen_tlm_maestro_hist,1);

insert into tlm_maestro_hist (id,modificado) values (:loc_nuevo_id, current_timestamp);

IF (new.Field1 is distinct from old.Field1) then
update tlm_maestro_hist set Field1 = old.Field1 where ID =

IF (new.Field2 is distinct from old.Field2) then
update tlm_maestro_hist set Field2 = old.Field2 where ID = :Loc_Nuevo_ID;

IF (new.Field3 is distinct from old.Field3) then
update tlm_maestro_hist set Field3 = old.Field3 where ID = :Loc_Nuevo_ID;