Subject GROUP BY and JOINs
Author Christian Gütter
Hi,

I have got a problem to join a selectable stored procedure to
a select statement that contains a GROUP BY clause.

This select statement works fine:

SELECT SUM(PS.Aktueller_Saldo), P.PID, P.Name1, P.Name2, P.ID
FROM T_Personal_Salden PS
JOIN T_Personal P ON P.ID = PS.Z_Personal_ID
GROUP BY PS.Z_Personal_ID, P.PID, P.Name1, P.Name2, P.ID
HAVING SUM(PS.Aktueller_Saldo) < 0
ORDER BY P.PID

Then I add a JOIN for the selectable stored procedure
P_Hole_Makler_Adressen:

SELECT SUM(PS.Aktueller_Saldo), P.PID, P.Name1, P.Name2, P.ID
FROM T_Personal_Salden PS
JOIN T_Personal P ON P.ID = PS.Z_Personal_ID
JOIN P_Hole_Makler_Adressen(P.ID) HMA ON HMA.O_Personal_Id = P.ID
GROUP BY PS.Z_Personal_ID, P.PID, P.Name1, P.Name2, P.ID
HAVING SUM(PS.Aktueller_Saldo) < 0
ORDER BY P.PID

When executing that statement, I receive the following error message:

"The cursor identified in the update or delete statement is not positioned on a row.
no current record for fetch operation."

Is this an expected limitation of Firebird 1.50?
If yes, is there a workaround?
Or is my query just badly written?


Thanks in advance!


Christian