Subject Re: [IBO] Invalid KeyLinks
Author Helen Borrie
At 11:32 AM 13/11/2003 +0000, you wrote:
>Given;
>
>select j.* , jt.jt_profit from TBL_JOBS j
>left join TBL_JOBTYPES jt on j.jb_type = jt.jt_code
>WHERE J.JB_ID = :JB_ID
>
>Can anyone tell me what the KeyLinks should be?
>
>I have tried;
>
>TBL_JOBS.JB_ID
>JB_ID
><BLANK>
>
>All return Invalid keylinks

What's <BLANK> supposed to do?

The controlling table in this query is j so, as a minimum, you need the
whole PK of tbl_jobs. Generally, the linking keys would be in the Keylinks
too, but you have a problem with the right-hand table because of the outer
join. In this case, you really have no option but to use the DB_KEY. You
can't use that for positioning an update but it should be enough to hold
the relative positions of the rows for the duration of the transaction.

Why would you want an outer join in this set? Why, in fact, would you want
a join at all? It appears like a lookup relationship to me...
select j.* ,
(select jt.jt_profit from TBL_JOBTYPES jt
where jt.jt_code = j.jb_type) as jt_profit
from TBL_JOBS j
WHERE J.JB_ID = :JB_ID

Keylinks for this is the PK of TBL_JOBS and it's an updatable dataset to boot.

Helen