Subject RE: [IBO] Generators and row selections
Author Don Schoeman
How did you guess that I'm a newbie Helen? Just kidding :) I must admit that
IBO does have a bit of a steap learning curve, but dam, I like it!

-Don


-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: 07 August 2001 11:15
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Generators and row selections


At 10:51 AM 07-08-01 +0200, you wrote:
>I have two problems:
>
>Firstly, I manually insert records to a dataset using methods like
>TIB_Query's Insert method. Even though I do have the KeyLinks property
>correctly set to the primary key of the table, the row cursor moves to the
>previously selected record after the post. I would like it to stay at the
>newly created record. I've tried setting the KeyLinksAutoDefine property to
>true instead of specifying the LeyLinks also, but it still doesn't work.
>What am I missing?

Set the RefreshAction property to raKeepDataPos.


>Also, I have a simple generator which increments the primary key of a table
>when inserting a new record. For some reason the generator add's 2 to the
>previously created value instead of 1. Am I doing something stupid again
>which will cause this behaviour?

You are probably doing something...um...fairly typical for a newbie.

You probably have GeneratorLinks set. This will fetch the key value from
the generator as the dataset is going into Insert mode. All is well at this
stage.

Then, your "simple trigger" is probably just TOO simple. It is saying
"new.ID = gen_id(mygen, 1)" when it should be testing for NULL, viz

if (new.ID is NULL) then
new.ID = gen_id(mygen, 1);

You only want the trigger to fire the generator if the value isn't supplied,
do you see?

The FAQ on the IBO website is a fairly useful resource for problems like
this...

Regards,
Helen