Subject RE: [firebird-support] Re: Complex generators?
Author Alan McDonald
> ----
> IF (NEW.SIFRA IS NULL) THEN BEGIN
>
> genname = 'GEN_MASTER_' || new.type;
>
> update my$gen set val = val + 1 where name=:genname; /* locks
> record, if any */
>
> select val from my$gen where name=:genname into :num;
> if (num is null) then begin /* no such counter exists */
> insert into my$gen values(:genname, 1);
> num = 1;
> end
> new.sifra = :num;
>
> END
> ----
>
> That, and CachingUpdates works as I initialy thought - Thanks
> everyone, I learned much in the process :)

Wow - Using DML on system tables and re-setting generator values from the
client - what a recipe for disaster in a multi-user environment! Good luck.
But believe me - you'll be back - you're going to have lots of problems now.

Alan