Subject Re: Generator problem
Author mk_delphi
This simple trigger work fine for mine low users network..
Place this is in AfterPost event:

declare variable LST integer;
BEGIN
LST=0;
select max(number)+1 from header_table
where extract(year from docdate)=extract(year from new.docdate)
into :LST;
if ((LST is null) or (LST=0)) then
LST=1;
update header_table set number=:LST where oid=new.oid;
END

Since I always close transacion after this post, never
appens a concurrency....(of corse in a little network)
NB: if the records are a lot using a desc
index on "number" will help.

Can someone own better solution than this?
(without the use of named generator...)
Ciao!

--- In ib-support@y..., "wvlange" <willem.van.langendonck@c...> wrote:
> I have the following problem for which I want a solution in FB 1.0
>
> I have an application that produces documents that are numbered per
> year. So I want to have number ranges per year. For every number
> range I defined a generator.
>
> Now I want to write a trigger that will give the correct document
> number based on the date of the document that is posted. Does
anyone
> have a suggestion on how this can be done ?