Subject | Re: Complex generators? |
---|---|
Author | ivoras |
Post date | 2003-12-28T23:20:24Z |
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@m...>
wrote:
----
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 :)
wrote:
> Does it matter to the person entering the data of the sales bill,that they
> know the ID of the bill as they enter it? They can enter the typepresumably
> but the ID can often remain greyed out in the entery form until acommit is
> actioned.You're right. I solved the problem by unsing this trigger:
----
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 :)