How can I control which field are being updated?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Elivaldo
Posts: 3
Joined: Wed 23 Aug 2017 16:37

How can I control which field are being updated?

Post by Elivaldo » Wed 06 Jul 2022 19:02

For example:

Code: Select all

SELECT id, name, salary, ‘n’ as modified FROM employees
If I change the fields SALARY and MODIFIED I would receive the error “Unknown column MODIFIED in field list”

OK. One solution would be the use of SQLUpdate property, specifying the sentence for update:

Code: Select all

UPDATE employees SET name = x, salary = y WHERE id = z
But… this implies that the field NAME would be updated even if the only field really changed is SALARY. And this could lead to problem. Imagine that, at the same time, ComputerA changes the field NAME and ComputerB changes the field SALARY. The data from the last computer to apply would prevail.

Could anyone please help me?

davidmarcus
Posts: 50
Joined: Tue 25 Jan 2005 11:22
Location: Somerville, MA
Contact:

Re: How can I control which field are being updated?

Post by davidmarcus » Thu 07 Jul 2022 16:46

Not sure I understand the question. If you have multiple clients updating the same data, you need some form of locking. There are various ways to do this.

Elivaldo
Posts: 3
Joined: Wed 23 Aug 2017 16:37

Re: How can I control which field are being updated?

Post by Elivaldo » Thu 07 Jul 2022 16:58

Thanks, David. Putting it simpler: Is there a way to tell TMyQuery not do update a certain field?

davidmarcus
Posts: 50
Joined: Tue 25 Jan 2005 11:22
Location: Somerville, MA
Contact:

Re: How can I control which field are being updated?

Post by davidmarcus » Thu 07 Jul 2022 17:54

I don't know. I usually use TMyCommand to do updates. I don't know what TMyQuery can do.

Elivaldo
Posts: 3
Joined: Wed 23 Aug 2017 16:37

Re: How can I control which field are being updated?

Post by Elivaldo » Thu 07 Jul 2022 22:20

Ok, David. Thanks.

pavelpd
Devart Team
Posts: 109
Joined: Thu 06 Jan 2022 14:16

Re: How can I control which field are being updated?

Post by pavelpd » Fri 08 Jul 2022 18:26

Hey,
Thanks for contacting us!

Kindly note, that we were unable to reproduce the "Unknown column MODIFIED in field list" error you mentioned based on the data you provided.
So could please compose and send us an sample application reproducing the error you have specified with all necessary DDL and DML scripts to create and populate database objects.
You can send all the needed samples via the e-support form: https://www.devart.com/company/contactform.html

Also, please send us the exact list of steps (actions) which leading to the error you indicated.
You can create and send us the screenshot demonstrating the issue.

Additionally, could you please clarify some additional information:
- What version of MyDAC do you have;
- What version of RadStudio;
- What version of the database;

Post Reply