Subject Re: [IBO] Dynamic Query
Author Helen Borrie
At 02:46 PM 05-09-02 +1000, you wrote:
>In my form where the user can browse a lookup table I have another grid next
>to it that I want to use to display all records from two other tables which
>are using the currently selected 'lookup' record.
>
>The table being browsed is called IPLOOKUP and the GROUPS/SPRITEDETAIL are a
>master/detail relationship where the SPRITEDETAIL.SD_IPLOOKUP field will
>match the IPLOOKUP.ID field. My query is designed to return all records
>from the master/detail tables that currently use the IPLOOKUP.ID field.
>
>My TIB_Query statement for the other grid is:
>
>SELECT GROUPS.GRP_DESCRIPTION,
> SPRITEDETAIL.SD_DESCRIPTION,
> SPRITEDETAIL.SD_CAMERA,
> SPRITEDETAIL.SD_IPLOOKUPID,
> IPLOOKUP.ID,
> IPLOOKUP.IPL_DESCRIPTION,
> IPLOOKUP.IPL_IPADDRESS,
> IPLOOKUP.IPL_LOCAL
>FROM SPRITEDETAIL
> INNER JOIN GROUPS ON (SPRITEDETAIL.SD_GROUPID = GROUPS.ID)
> INNER JOIN IPLOOKUP ON (SPRITEDETAIL.SD_IPLOOKUPID = IPLOOKUP.ID)
>WHERE SD_IPLOOKUPID = :ID
>
>
>The query has been tested in an external application and it works fine so I
>know I have a configuration issue.
>
>* The KeySource for this query points to the datasource connected to
>IPLOOKUP
>
>* KeyLinks for this query is set to SD_IPLOOKUPID
>
>* RequestLive is true
>
>I'm using the same transaction component for all TIB_Query components
>concerned.
>
>Without the last line in the SQL I get all records (but they are wrong) and
>when using this last line I get no records (also wrong).
>
>What have I forgotten or done wrong ?

Wrong this time. This isn't a keysource-lookup relationship but master-detail.

So your joined dataset (the detail) has to point to IPLOOKUP as its master
via the MasterSource property (of the detail set). You probably need to
use MasterParamLinks for this one, rather than MasterLinks. If you are
stuck, grab the TI sheet on Master-detail setups.

You don't have any Keysource-Lookup relationship here at all so make sure
to take it out and alter the KeyLinks property to be the unique key of the
joined dataset. RequestLive on this dataset won't work unless you have
"dedicated" xxxxxSQL properties on this detail dataset (parameterised
EXECUTE PROCEDURE calls, natch). If, OTOH, you want only ONE of the
contributing tables in that dataset to be updatable, you can use
KeyRelation instead to make it live.

Helen