Subject | Re: Error with joins and auto-generated search query (Firebird 1.5.3) |
---|---|
Author | Jason Wharton |
Post date | 2006-11-22T19:30:54Z |
Marco,
This issue is because Firebird 2.0 does not return the relation
alias name, nor a relation name for the columns participating in the
GROUP BY aggregation.
My only resort is to parse the SQL and look for a table alias being
used on the column name, which you are doing, and override what the
server returns so that we can have an accurate query put together
that won't trip up on the ambiguous column problem.
I believe it would be a good idea to raise this issue with the
Firebird development team and challenge them on not returning the
relation alias used.
Jason Wharton
This issue is because Firebird 2.0 does not return the relation
alias name, nor a relation name for the columns participating in the
GROUP BY aggregation.
My only resort is to parse the SQL and look for a table alias being
used on the column name, which you are doing, and override what the
server returns so that we can have an accurate query put together
that won't trip up on the ambiguous column problem.
I believe it would be a good idea to raise this issue with the
Firebird development team and challenge them on not returning the
relation alias used.
Jason Wharton
--- In IBObjects@yahoogroups.com, "Marco Menardi" <mmenaz@...> wrote:
>
> 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
>