TableAlias not correct
Posted: Wed 12 Oct 2016 08:06
Hi,
I've the following SQL
so the same table is invoked two times.
When I try to get the fieldnames with tablealiases always "l1" is returned and never "l2".
Seems the TCRFieldDesc doesn't contain the correct Alias when same tables is included multiple times.
best regards
Toni Santa
I've the following SQL
Code: Select all
select top 100 l1.id, l1.id_first_titolare ,
l2.id, l2.id_first_Titolare
from link l1 inner join link l2 on l1.id = l2.id_first_titolare
order by l1.id
When I try to get the fieldnames with tablealiases always "l1" is returned and never "l2".
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
FieldDesc: TCRFieldDesc;
Field: TField;
TblName: string;
begin
msquery1.active := true;
for i := 0 to msQuery1.Fields.Count - 1 do
begin
Field := msquery1.Fields[i];
if Field.FieldKind <> fkData then
continue;
FieldDesc := TCRFieldDesc(msQuery1.GetFieldDesc(Field));
TblName := FieldDesc.TableInfo.TableAlias;
memo1.lines.add(TblName + '.' + FieldDesc.ActualName);
end;
end;
best regards
Toni Santa