Page 1 of 1

TableAlias not correct

Posted: Wed 12 Oct 2016 08:06
by tonisanta
Hi,
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
so the same table is invoked two times.
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;
Seems the TCRFieldDesc doesn't contain the correct Alias when same tables is included multiple times.
best regards
Toni Santa

Re: TableAlias not correct

Posted: Mon 14 Nov 2016 14:41
by azyk
Thank you for the information. We have reproduced the problem and will investigate it.

Re: TableAlias not correct

Posted: Fri 20 Jan 2017 15:30
by azyk
We have fixed this problem. This fix will be included in the next SDAC build.