Subject | Re: [firebird-support] embeded. Trigger doesn't fire? |
---|---|
Author | Thomas Steinmaurer |
Post date | 2009-10-10T18:50:07Z |
>> be careful, depending on how you set up your ibdataset, you may have toTo generate a primary key value via a generator in a trigger, which is
>> generate your value by code in your application (or through the IBX
>> components using the according properties) (yes, in that specific case,
>> triggers are useless)
>
> Thanks for the input! May I ask again? I don't quite undestand... In what case
> triggers are useless?
needed in the client application *before* posting the newly inserted
record, because this simply is not possible as the PK value is generated
at the server.
So, you can:
* Fetch the next generator value in your client application and apply
that value to the PK field and you are done. The trigger should be
implemented that way to prevent increasing the generator value again.
* If you don't have to set the pk value in your client application
(because you have set Required at TField level to False), then either do
a Refresh on your dataset to retrive the server-side generated PK value
or if your access component supports Firebird's INSERT INTO ...
RETURNING syntax in some way, you can get back the PK value in the
context of your INSERT INTO statement without re-fetching records from
the server.
HTH.
--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com
My blog:
http://blog.upscene.com/thomas/