Subject RE: [IBO] Getting the value of a generator
Author Dayna
You could use a trigger in the database table that writes the next generator
value to the table during insert. Then get that value that was written
before writing the 2nd part of your write.





Dayna







From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf
Of Craig Cox
Sent: Friday, April 13, 2012 05:20 AM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Getting the value of a generator





Helen, as always - Thanks for your timely post.

As you can probably tell, I am using the primary key in my master table to
identify records in a detail table. I am getting the anticipated value of
the new master record before it is committed in case the user decides not to
commit. If the user commits, it all goes great unless another user happens
to sneak in. This will not likely be the case in this database (famous last
words). I would, however, prefer to do it the right way, but not sure how to
approach it. Any suggestions on avoiding mismatches?

--- In IBObjects@yahoogroups.com <mailto:IBObjects%40yahoogroups.com> ,
Helen Borrie <helebor@...> wrote:
>
> At 09:54 AM 13/04/2012, Craig Cox wrote:
> >(Firebird 1.5+, Delphi XE, IBOjects)
> >
> >I'm guessing there is a very simple answer to this problem.
> >
> >I want to get the current generator value of one table
>
> Tables don't have generators. A generator is a self-contained sequence.
You'll need to know the name of the generator that is used to populate the
column in question, then you can use GeneratorValue(Name_of_Generator, 0) to
get the latest value that has been generated.
>
> >, increment it in Delphi and use the new value in another table. I
thought the GeneratorValue() method looked promising, but I may not
understand it well enough to use it properly. If you can tell me how to get
the value of the generator, I think I can figure out the rest.
>
> Sounds dicey, unless your database has only one user.
>
> Helen
>





[Non-text portions of this message have been removed]