Subject Error with joins and auto-generated search query (Firebird 1.5.3)
Author Marco Menardi
IBO 4.6.Aa Firebird 1.5.3, Delphi 6 pro, Windows2000sp4.
I have a problem using native IBO controls and the "search" mode with
Firebrid 1.5.3 that is less forgiving about ambiguos field name. IBO
automatically generates a query that has no table qualifier, and if
that field is present in both tables I join, I get an error... how can
I avoid it? I've tried setting "KeyRelation" property (I know it's
used for upates, but, you know...) or keylinks (but got an error...)
but without success. Any clue?
The query is:
SELECT FORNITORI.FORNITORE_ID
, FORNITORI.DESCRIZIONEDISP
, SUM(SCADENZIARIO.TOT_CHIUSO) AS CHIUSO
, SUM(SCADENZIARIO.TOT_APERTO) AS APERTO
, SUM(SCADENZIARIO.TOT_CHIUSO - SCADENZIARIO.TOT_APERTO) AS SALDO
FROM FORNITORI
INNER JOIN SCADENZIARIO ON (FORNITORI.FORNITORE_ID =
SCADENZIARIO.FORNITORE_ID)
GROUP BY FORNITORI.FORNITORE_ID, FORNITORI.DESCRIZIONEDISP

When IBO generates the query searching for FORNITORE_ID value you have:
SELECT FORNITORI.FORNITORE_ID
, FORNITORI.DESCRIZIONEDISP
, SUM(SCADENZIARIO.TOT_CHIUSO) AS CHIUSO
, SUM(SCADENZIARIO.TOT_APERTO) AS APERTO
, SUM(SCADENZIARIO.TOT_CHIUSO - SCADENZIARIO.TOT_APERTO) AS SALDO
FROM FORNITORI
INNER JOIN SCADENZIARIO ON (FORNITORI.FORNITORE_ID =
SCADENZIARIO.FORNITORE_ID)
WHERE FORNITORE_ID STARTING 'FF0001'
GROUP BY FORNITORI.FORNITORE_ID, FORNITORI.DESCRIZIONEDISP
ORDER BY DESCRIZIONEDISP DESC


and then, of course, the error:
Project ammwine2000.exe raised exception class EIB_ISCError with
message 'ISC ERROR CODE:335544569
ISC ERROR MESSAGE:
Dynamic SQL Error
SQL error code = -204
Ambiguous field name between table FORNITORI and table SCADENZIARIO
FORNITORE_ID
'. Process stopped. Use Step or Run to continue.

So I need a way to tell IBO to make something like:
WHERE FORNITORI.FORNITORE_ID STARTING 'FF0001'

Btw, if I set KeyLinks to FORNITORI.FORNITORE_ID and I simply open the
query I get the error:
Invalid KeyLinks entry: FORNITORI.FORNITORE_ID.

Any help is much apreciated, thanks
Marco Menardi