Subject | AW: [firebird-support] problem trigger after insert and generator |
---|---|
Author | Olaf Kluge |
Post date | 2011-09-16T09:01:58Z |
Hello,
I think not, it will be delete if the second generator >= 30:
AS
declare variable ist integer ;
begin
ist=GEN_ID(TILOG_ALLG_ID_DEL, 1);
//The generator adding up (+1)
if(ist >= 30) then
// if the generator = 30 then begin
begin
ist = gen_id(TILOG_ALLG_ID_DEL, -10);
// set generator - 10
ist = new.id -20;
// take the record-id -20
delete from tilog_allg where id<=:ist;
// delete all records smaller then record-id - 20
end
end
In this case, every 10 records will be delete the oldest 10 records. But it
doesn't works every time!
What can it be?
May be in the before insert trigger do
new.ID = GEN_ID(TILOG_ALLG_ID_DEL, 1);
ist=new.ID - 30;
delete from tilog_allg where id<=:ist;
There may be concurrency problem, but could be solved if you do
delete from tilog_allg where id=:ist; //
You only delete the ID of the current record less 30, then 31 will delete
ID=1, when 32 is inserted will delete 2.
Regards, Jesus
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
I think not, it will be delete if the second generator >= 30:
AS
declare variable ist integer ;
begin
ist=GEN_ID(TILOG_ALLG_ID_DEL, 1);
//The generator adding up (+1)
if(ist >= 30) then
// if the generator = 30 then begin
begin
ist = gen_id(TILOG_ALLG_ID_DEL, -10);
// set generator - 10
ist = new.id -20;
// take the record-id -20
delete from tilog_allg where id<=:ist;
// delete all records smaller then record-id - 20
end
end
In this case, every 10 records will be delete the oldest 10 records. But it
doesn't works every time!
What can it be?
May be in the before insert trigger do
new.ID = GEN_ID(TILOG_ALLG_ID_DEL, 1);
ist=new.ID - 30;
delete from tilog_allg where id<=:ist;
There may be concurrency problem, but could be solved if you do
delete from tilog_allg where id=:ist; //
You only delete the ID of the current record less 30, then 31 will delete
ID=1, when 32 is inserted will delete 2.
Regards, Jesus
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]