Hello,
I have a rather urgent issue.
I have a join in a customer Delphi server using IbDac.
The join works perfectly well in the schema modeler.
When opening the table on the client, everything is working perfectly also.
Problem is when I try to use a dynamicwhere on the table.
The join consists of 3 tables, each containing a field removed to indicate that the record is removed.
So I have query with the main table files that contains the required fields and the field removed. It also contains the fields needed from the 2 other tables with without the field removed.
When I try to use dynamicwhere on the field removed, it gives me ambigious field.
I’ve tried with an alias for the field but then the table gives me unknown field removed when trying to use dynamicwhere.
SELECT FILES.ID, FILES.FILETYPE, FILES.STATUS, FILES.NAMEFILE, FILES.ORDERED,
FILES.SEND, FILES.DATESTARTEVENT, FILES.DATEENDEVENT, FILES.GENERALTOTAL, FILES.COMPANYID, FILES.REMOVED AS FILEREMOVED, RELATIONS.COMPANYNAME AS CUSTOMERCOMPANYNAME, RELATIONS.NAME || ’ ’ || RELATIONS.FIRSTNAME AS CUSTOMERFULLNAME, RELATIONS.REMOVED AS RELATIONREMOVED,
CONTACTS.NAME || ’ ’ || CONTACTS.FIRSTNAME AS CONTACTFULLNAME, CONTACTS.REMOVED AS CONTACTREMOVED
FROM FILES
LEFT OUTER JOIN RELATIONS ON (FILES.RELATION = RELATIONS.ID)
LEFT OUTER JOIN CONTACTS ON (FILES.CONTACT = CONTACTS.ID)
WHERE
{WHERE}
the relations table also contains a removed field and the contacts table also.
I have tried with this statement (now in comment):
I have changed the query in the schema modeler to this, which validates:
SELECT FILES.ID, FILES.FILETYPE, FILES.STATUS, FILES.NAMEFILE, FILES.ORDERED,
FILES.SEND, FILES.DATESTARTEVENT, FILES.DATEENDEVENT, FILES.GENERALTOTAL, FILES.COMPANYID, FILES.REMOVED, RELATIONS.COMPANYNAME AS CUSTOMERCOMPANYNAME, RELATIONS.NAME || ’ ’ || RELATIONS.FIRSTNAME AS CUSTOMERFULLNAME,
CONTACTS.NAME || ’ ’ || CONTACTS.FIRSTNAME AS CONTACTFULLNAME
FROM FILES
LEFT OUTER JOIN RELATIONS ON (FILES.RELATION = RELATIONS.ID)
LEFT OUTER JOIN CONTACTS ON (FILES.CONTACT = CONTACTS.ID)
WHERE
{WHERE}
Ok,
when not specifying tablenames, I get the following error:
Ambiguous field name between table CONTACTS and table FILES and table RELATIONS REMOVED.
When specifying the table I get the following error:
Column unknow FILES.REMOVED
I have tried this with AllowAllFieldsInDynamicWhere true of false.
can you check SQL that was sent to IBDAC?
it can be checked in TDAEBaseDataset.DoSetActive (uDAEBaseDataset.pas) .
set breakpoint at NativeDatabaseAccess.Active := True; line and evaluate SQL (or GetSQL).
also you can check properties of native IBDAC object with TIBCQuery(Dataset)
I’m running through the sourcecode and what I find strange is that in uDAEBaseDataset in the DoSetActive I thet the following return value from GenereateDynmaicWhereStatement:
‘((“Files”.COMPANYID = 1) AND (“Files”.REMOVED = :DAPARAM_1))’