Search found 3 matches

by Elivaldo
Thu 07 Jul 2022 16:58
Forum: MySQL Data Access Components
Topic: How can I control which field are being updated?
Replies: 5
Views: 9864

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

Thanks, David. Putting it simpler: Is there a way to tell TMyQuery not do update a certain field?
by Elivaldo
Wed 06 Jul 2022 19:02
Forum: MySQL Data Access Components
Topic: How can I control which field are being updated?
Replies: 5
Views: 9864

How can I control which field are being updated?

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?