Subject Re: [IBO] SP's in Master-Detail Relationships...
Author Lucas Franzen
Kaputnik schrieb:
>
> Hi,
> I have one problem......
>
> I have a database with between 1-6 Mill. Rows per Table
> In order to do a small Master-Detail Lookup, I created a SP with a PK as
> Input-Parameter, which is doing a Join over 4 Tables. Doing this in a View
> would kill the IB-Server for a long while, although the Query-Optimizer does
> it's job astonishingly good and uses all inidzes as intended.
>
> This SP is intended for a Master-Detail-Relationship, where the user can
> browse through the custoemrs, and view all the different articles, which he
> ordered in all his past orders....
> I would like to know, if and how it would be possible to include this SP
> into an IB_Query to have the MD-updates handled automatically....
> The SP is selectable and has only one input-paramter (the Customer-No.) and
> 4 output-variables....
> Is it possible to do this like this? Select * from SP(paramters) and handle
> the rest in the master-links??

Selecting from a SP is like slecting from a table or view.

You do just enter:

SELECT <FIELDS> from SP_NAME ( :PARAM1, :PARAM2, ...)

The MasterLinks should work, too, though I haven't tested it so far.

One problem I experienced with selecting data from a SP with an IB_Query
was that you better leave the KeyLInks property empty and set
KeyLinksAutoDefine to TRUE.
In my case stepping throught he result set, took appr. 1 min for 100
records when I self-defined the KeyLink (it was the PK of the underlying
table).
When using KeyLinkAutoDefine it went back to normal speed.

But I'm not sure why you do want to use a SP for selecting the detail
data.
You should be able to get the 4 table join within a 'regular' query just
as fast as from a SP.

Im my experience SP's aren't faster in selecting, but they do offer the
opportunity to write more complex SQL-Statements (you can handle
IF..THEN, etc).

Regards
Luc.