Master - Details

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pjungersen
Posts: 6
Joined: Mon 11 Dec 2006 17:39

Master - Details

Post by pjungersen » Fri 15 Dec 2006 08:17

In my old version 3.50 this works - after upgrade to 4.40 i have got the following problem

A simple SQL

Select *
from TableA, TableB
Where
TableA.Field1 = TableB.Field1
and
TableA.Field1 = :Field1

I get the error : Field1 is ambiguous

Masterdatasource - has Field1

A look in the DBMoitorer
Shows that the real SQL send to MySql is

Select *
from TableA, TableB
Where
( TableA.Field1 = TableB.Field1
and
TableA.Field1 = :Field1) and Field1 = :Field1

What to do

/Per

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 15 Dec 2006 13:06

This looks like you have combined two types of master/detail relationship in this example:
1. by parameters, because the following condition appears in your query: TableA.Field1 = :Field1;
2. by MasterFields/DetailFields, because the following condition appears in the query caught by DBMoitor: and Field1 = :Field1. It is added by MyDAC.
There is no need to use both links simultaneously for a single relationship. If you decide to use the first link type, you should just clear the MasterFields and the DetailFields properties. Otherwise you should remove this condition: TableA.Field1 = :Field1 from your detail query and change the DetailFields property so that field name appears with the table name: TableA.Field1.

Post Reply