Subject | Re: [IBO] field value after an insert that is not part of the insert |
---|---|
Author | Helen Borrie |
Post date | 2004-09-23T01:27:41Z |
At 01:09 AM 23/09/2004 +0000, you wrote:
- that's what GeneratorLink does. It's necessary to ensure that your
trigger can handle getting the value via GeneratorLinks (or its underlying
method, Gen_ID()):
The trigger code:
if (new.YourPk is null) then
new.YourPk = GEN_ID(YourGenerator, 1);
If the GeneratorLink is set, you can read its value into a variable at
BeforePost. If you use IBO's Gen_ID() function yourself (available on both
the connection and the statement objects) you can get the value sooner if
you need it. Don't set the GeneratorLink if you call Gen_ID().
And, no, it's not safe to attempt to find out the value AFTER the commit.
Helen
>If I execute a SQL 'insert' how do I get a field's value (generatedIn Firebird/IB, the trick is to get the value *before* you post the insert
>in the trigger) after it is inserted? I have the
>IB_Connection.GeneratorLink (so I guess I could parse the .Text and
>get the ID to include in the SQL)--but is there an easier
>(different) way? I have a process that is generic so far and getting
>that ID looks like the last stumbeling block.
- that's what GeneratorLink does. It's necessary to ensure that your
trigger can handle getting the value via GeneratorLinks (or its underlying
method, Gen_ID()):
The trigger code:
if (new.YourPk is null) then
new.YourPk = GEN_ID(YourGenerator, 1);
If the GeneratorLink is set, you can read its value into a variable at
BeforePost. If you use IBO's Gen_ID() function yourself (available on both
the connection and the statement objects) you can get the value sooner if
you need it. Don't set the GeneratorLink if you call Gen_ID().
And, no, it's not safe to attempt to find out the value AFTER the commit.
Helen