Subject RE: [IBO] Unusual behaviour IB_Grid
Author Helen Borrie
At 01:58 PM 22/06/2004 +0200, you wrote:
>Thanks Helen
>Will try this tonight.
>I use a system that runs concurrent with a numeric filing system. The
>generator Id is the file Nr for the patient.
>If the user presses insert to insert a new patient, but then decides to
>cancel, the generator Id has moved on +1, and the file ID is thus lost
>to the numeric filing system.
>This then results in one having file 2304,2305,2307,2310 .. with skips
>in between.
>That is why I was using the method illustrated below, in the before post
>Can I do this with the Generator Links method?

First: DO NOT use data columns as keys. Make your keys independent of any
user data. A file number is *definitely* user data: even MORE SO if you
can't tolerate gaps in the sequence.

Next (aside from that design flaw) - don't bother with GeneratorLinks if
you don't have a need to know the generator number before you reach
Post. Get it at BeforePost if you will (or, better, use a trigger) but use
the Gen_ID() function. You can call this as a method of either the
connection object or the dataset.

To make your datasets behave properly after Posts, I can't stress enough
the importance of correct KeyLinks.

Now, as to your file numbers, do relegate them to data-only columns and add
proper atomic keys. It is possible to maintain "gapless" sequences from
generators but you definitely should NOT apply such techniques to
keys. I'm hesitant to direct you the TI-sheet on maintaining an auditable
sequence at this stage, as you don't yet seem to have a solid understanding
of how the server-side stuff works.

Another method is easier to get your head around if you are already trying
to take a lot of new concepts on board. That is to keep a table of file
numbers which you populate from a dedicated generator. From this table you
allocate a number to a requesting application and flag it as "used". If
the user cancels, you can swoop back in and "unflag" that number.

You can build in a trigger to populate this table with a fresh batch of
numbers when the count of unflagged numbers gets below a certain threshold.

>Perhaps I'm a bit stupid, but have always found the double click on
>Query, then you can fill in master links, key links, etc, very confusing
>to use.
>Is there an excellent documentation on this very powerfull feature

Yes, there is. It's called "Getting Started with IBObjects" (known as "the
GSG"). It isn't a "freebie" - you can purchase it from the community page.

You might like to take a close look at the help file for the IB_SQL
program. IB_SQL is actually the same program that runs modally when you
double-click on an IB_Connection glyph in the IDE.
>Can you refer me to documentation on the use of links generators, server
>side, I'm doing all in code, and will like to try it your way!

The GSG. Or download most of the TechInfo (TI sheets) from the TechInfo
page of the main website. And use the online FAQ !

For server-side stuff, use the firebird-support list.