Subject Re: [IBO] Current record refresh in TIBOQuery
Author Geoff Worboys
> Sounds like an interesting idea, but I don't know how to
> implement it. In this case the master would be a set of
> records, just the keys I suppose, and the detail dataset
> would have the same records with all the required fields.
> But the detail dataset is connected to a grid and must
> be scrollable. I don't know how that can be done.

Hmmm, yes you understood the idea as I meant it, but the grid
requirement does sort of upset things a bit.

I dont think JoinLinks will help you. That property is there for
people wanting to do implicit joins rather than 'JOIN xxxx ON' syntax.

Here is a different idea, still using two datasets but without master
detail relationship.

You have your main selection dataset, presumably with just the keys
although that may depend on other requirements. The where clause with
this dataset will apply the full restrictions required.

You have a second independant dataset selecting all the required
fields and using the IDENTICAL keylinks definition of the first. The
where clause for this dataset would be almost the same as the main,
but would not check the status field that is causing you problems.
Make sure FetchWholeRows is true. To this dataset you attach code to
the OnFilterRecord event that does something like...

uses IB_Utils; // for BinaryToHexText function

procedure Form1.SecondDatasetOnFilterRecord( ARow: TIB_Row;
var Accept: boolean );
tmpBkmk: string;
// Calculate bookmark string for supplied row
tmpBkmk := BinaryToHexText( ARow.RowNode.KeyData,
SecondDataset.NodeList.KeyDataLength );
// Try to get main dataset to match rows
MainDataset.BufferBookmark := tmpBkmk;
// If row not found in maindataset then dont accept it.
if MainDataset.BufferRowNum = 0 then
Accept := false
Accept := true;

I have not tried building a bookmark in this way before, but AFAICT
the code shown above should be OK. If Jason is watching; how about a
direct function for this purpose?

Obviously this is not totally efficient, since the SecondDataset will
be retrieving more records than it needs from the server, and then
discarding those that are not found in the MainDataset. However it
will allow you to refresh the second dataset independantly of the
MainDataset (keeping records that are still selected by the
unrefreshed main dataset) and will also allow you to attach the second
dataset to a grid for normal scrolling etc.

I have NOT tried this before so I cannot be certain it will work
exactly how you want. Its the best I can come up with at short notice

Geoff Worboys
Telesis Computing