Subject RE: [firebird-support] RE: Generator
Author Alan McDonald
> Eduado,
>
> Read the Generated number from the database before you post
>
> Generally somthing like
> select gen_id (generator,0) from rdb$database and this will
> return the next
> number in generator
>
> When you insert your record
> set rowid from previous select
>
>
>
>
> in your before insert you will need to have
> if (RowId is null) then
> RowId = Gen_Id(GeneratorName, 1);
>
>

This won't work when a few people start using your app simultaneously.
You need to actually select next one
Gen_Id(GeneratorName, 1);
and then insert this value with your new record
Your trigger will not get a new value since rowid s not null
AND by this method you already have the rowid to select again when you
finish
Alan

>
>
>
> >Hi!
> >
> >A have a generator as a primary key but after I
> execute the command
> >ApplyUpdates I need to recover the number to show for
> user. I'm use
> >dbEdit´s, SQLConnection, SQLDataSet, Provider,
> ClientDataSet and
> >FireBird 1.5.
> >
> >I' need help.
> >
> >Thank you.
> >
> >Eduardo
> >Brasil
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>