Subject problem trigger after insert and generator
Author Olaf Kluge
Hello,



I would like to delete records if a determined count of record is reached.
One trigger counts a generator for the primery key of the table named a. on
before insert. One trigger after insert counts a second generator like this:



AS

declare variable ist integer ;

begin

ist=GEN_ID(TILOG_ALLG_ID_DEL, 1);

if(ist >= 30) then

begin

ist = gen_id(TILOG_ALLG_ID_DEL, -10);

ist = new.id -20;

delete from tilog_allg where id<=:ist;

end

end



Some time it works, some time not! There were records inserted, but the
generator tilog_allg_id_del will not count every time and then the records
will not be deleted.



I like to delete the oldest records.



What can it be? I have also test it with read values from a table instead of
the static 30, 20, 10, of course with the same result. The generator will
not be count every time and then the records still present.



Thank you.



Best regards.



Olaf







[Non-text portions of this message have been removed]