Subject [firebird-support] Re: GROUP BY and JOINs
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, Pavel Menshchikov wrote:
> CG> The example can be simplified to a simple join of a table and a
> CG> selectable stored procedure.
> CG> This does not work:
>
> CG> SELECT PS.Z_Personal_ID, HMA.O_Personal_ID
> CG> FROM T_Personal_Salden PS
> CG> JOIN P_Hole_Makler_Adressen(PS.Z_Personal_ID) HMA ON
> CG> HMA.O_Personal_Id = PS.Z_Personal_ID
>
> CG> Error message:
> CG> ISC ERROR CODE:335544348
> CG> ISC ERROR MESSAGE: no current record for fetch operation
> As I understand, with inner joins FB for some reasons puts the
> stored procedure at the first place (as a left dataset), and then
> joins the rest tables with it. Since the stored procedure uses
> fields from the "following" tables, it doesn't "know" the value of
> those fields when executing. Outer join "forces" the join order.

Does this mean that preventing the PS.Z_Personal_ID index from being
used like

SELECT PS.Z_Personal_ID, HMA.O_Personal_ID
FROM T_Personal_Salden PS
JOIN P_Hole_Makler_Adressen(PS.Z_Personal_ID) HMA ON
HMA.O_Personal_Id = PS.Z_Personal_ID+0

could work as well? Or maybe you would have to do something like

SELECT PS.Z_Personal_ID, HMA.O_Personal_ID
FROM T_Personal_Salden PS
JOIN P_Hole_Makler_Adressen(PS.Z_Personal_ID) HMA ON
HMA.O_Personal_Id = PS.Z_Personal_ID
where PS.PK < 1000000000 //a very high number

The thought of accessing the SP before the table has simply never
occured to me before...

Set