Subject Re: [IBO] KeyLinks Format
Author Cam
Thanks Helen. Generator links of course it what I needed to use. Yes
all my generator triggers are test for nulls before Gen_id.

Thanks again

On 15/04/2014 8:54 PM, Helen Borrie wrote:
> At 07:28 p.m. 15/04/2014, Cam wrote:
>> Hi
>> I'm updating an old program that uses TIOBTables and cannot change this.
>> I have added a primary key field, ID to the table and attempted to use a
>> trigger to set the value of ID.
>> The exception Field 'ID' must have a value gets here before the trigger
>> executes.
>> Have tried to use the keylinks property to overcome this
> That's not what KeyLinks does. You want GeneratorLinks. Read on...
>> but cannot get the format correct.
>> I have purchased the getting started pdf but cannot find the format for
>> keylinks definition.
>> The best I have found is
>> "The syntax for this generalized purpose of KeyLinks is simply a column
>> name per line."
> That is exactly what the format is. Suppose you have a table with two columns in its primary key, Product_id and Version_id. You would enter the KeyLinks as
> Product_id
> Version_id
>> Cannot find any examples.
> Now you have one. :-) Of course, KeyLinks gets a bit more complicated on joined and other complex datasets but it's not an issue when your dataset is a TIBOTable.
>> Any clues appreciated.
> Back to your problem. A trigger is a server-side facility. IBO has no knowledge of the trigger. However, it helps you here by providing the GeneratorLinks property which, under the hood, will cause the Insert method to query the named generator and return the latest value. It is available both at dataset level (on TIBOTable in your case) and at connection level. The format (which you can find in the Help text for TIB_Dataset) is:
> [< tablename >.]< columnname >=< generatorname >
> See the Contact sample application to see this implemented.
> If you use it at dataset level you don't need the <tablename> unless you are performing an insert from a joined set. At connection level, the <tablename> is required.
> Caution: do make sure you write a safe BEFORE INSERT trigger by testing for NULL before calling GEN_ID or NEXT VALUE FOR.
> Helen