HowTo update *renamed* fields?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Minotaurus007
Posts: 14
Joined: Wed 27 Aug 2008 16:03

HowTo update *renamed* fields?

Post by Minotaurus007 » Sun 15 Feb 2009 15:25

TMyQuery renames fields if they are identical in two tables:
T1.ID, T2.ID => QueryFields: ID, ID_1;
Setting

Code: Select all

Query->UpdatingTable = "T2";
doesn't really help because subsequent update operations raise an exception: "Field ID_1 cannot be found in T2".

Workaround, if all fields from both tables (SELECT *) are required? :?:

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 19 Feb 2009 11:53

In order to solve the problem you can rewrite a SQL query using the AS statement, like this:

Code: Select all

SELECT T1.ID AS ID1, T2.ID AS ID ...
Also you can use SQLUpdate property to specify the SQL statement that will be used when applying an update to a dataset. You can find more detailed information about this property in the MyDAC help.

Post Reply