Underlying Table & Field corresponding with Column

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dadeishk
Posts: 6
Joined: Wed 06 Jun 2012 19:36

Underlying Table & Field corresponding with Column

Post by dadeishk » Wed 06 Jun 2012 20:46

Is there a way to derive the underlying table and field for a given column name?

For Example:

SELECT Memberships.Description AS MembershipName, CustomerMemberships.Date as Enrolled, Customers.FirstName+' '+Customers.LastName As Person
FROM Memberships INNER JOIN
CustomerMemberships ON Memberships.MembershipID = CustomerMemberships.MembershipID INNER JOIN
Customers ON CustomerMemberships.CustomerID = Customers.CustomerID


Given the following column name "MembershipName"

Is there a method to derive "Description" as the underlying Field and "Memberships" as the underlying Table?

I realize the circumstances that where Table and field names could not be derived, such as the "Person" column which results from concatenated fields.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Underlying Table & Field corresponding with Column

Post by AlexP » Mon 11 Jun 2012 13:06

Hello,

When you know the field alias, you can retrieve the real field name, the table alias and name in the following way:

Code: Select all

 TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).ActualName;  <-- the real field name
  TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).TableInfo.TableName; <-- the real table name 
  TCRFieldDesc(UniQuery1.GetFieldDesc('MembershipName')).TableInfo.TableAlias; <-- the table alias

dadeishk
Posts: 6
Joined: Wed 06 Jun 2012 19:36

Re: Underlying Table & Field corresponding with Column

Post by dadeishk » Thu 14 Jun 2012 15:35

Perfect. Thank you. :D

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Underlying Table & Field corresponding with Column

Post by AlexP » Thu 14 Jun 2012 16:16

hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

Post Reply