Subject Re: [IBO] IB_Query/SP/KeyLinks
Author Helen Borrie
At 06:32 PM 29/10/2004 +1000, you wrote:

>I have an IB_Query set with the following SQL
>SELECT FIELD1, FIELD2, FIELD3 FROM LOAN_S_ALL(:FK_SECCODE) WHERE ...
>I have the KeyLinks property set to 'FIELD1'
>and the MasterParamLinks set to 'FIELD3=FIELD3'
>where this field is present in the mastersource datasource dataset.
>
>Now my question is - How does the keylinks record get resolved here if this
>one record is being refreshed?
>
>I ask this question because I am now getting a "cursor unknown error" and
>I'm pretty sure it's from this query.

Yes, it is from this query...there is no cursor on the output of a stored
procedure.

>Is there some additional setting I should be obeying? What other way can I
>set the keylinks property?

It's not the KeyLinks that is the problem, it's the MasterParamLinks. A
MasterParamLink binds the parameter (or parameters, in the case of a
multi-column foreign key/primary key linkage) in the detail query to the
respondent key in the master.

This works fine when theres's a cursor open for the detail set. Each
scroll of the master causes the detail dataset to select the bound rows in
from the cursor that is opened on the detail table.

With a SP as your detail set, there is no cursor, so there can't be a WHERE
clause. Even if you have the parameters right (which you haven't), the SP
has to execute each time the master scrolls. To make this work, you have
to write a SSP that takes only the bound master field(s) as its input.

Inside the SP, the input value is used in the where clause of your
FOR...SELECT statement.

Once you have this SSP defined, your master-detail setup would then look
like this:

SELECT FIELD1, FIELD2, FIELD3 FROM LOAN_S_ALL(:FIELD3)
KeyLinks property set to 'FIELD1'
and the MasterParamLinks set to 'FIELD3=Mast.FIELD3'
where "Mast" is the name of the table that has FIELD3 either as its primary
key or as another unique key.

Helen