(Caluclated) "Field XXX cannot be modified" in ZQuery OnCalc event?

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
tomr
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 20.03.2017, 11:20

(Caluclated) "Field XXX cannot be modified" in ZQuery OnCalc event?

Post by tomr »

Hi!

I am migrating some IBX/Firebird code to ZEOS/Firebird (in Delphi 2009) and I have met strange issue: I have simple ZQuery with ZUpdateSQL and ZQuery has some calculated fields and one editable field. When I am opening query then calculated fields are calculated without problems. But when I am changing the value of the editable field then the error message is raised "Field XXX cannot be modified" upon first assignment in OnCalc event handler. Is this by design? What I am doing wrong?

TZQuery is very similar to TQuery (BDE) and TQuery allows to have calculated and editable fields in the same query.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: (Caluclated) "Field XXX cannot be modified" in ZQuery OnCalc event?

Post by marsupilami »

Hello tomr,

this is expected behaviour, if you select the calculated fields in a query like this:

Code: Select all

select a, b, a+b as c from mytable
If your code is like this, and you don't use TZUpdateSQL, then c will be a read only data field. If I understand correctly what you do you need to select the data without c and then add a field of the kind fkCalculated to the TZQuery on the Delphi side. I would assume that things also work like this in IBX? OnCalcFields is only to be used for fields of kind fkCalculated and not for fields of kind fkData.

With best regards,

Jan
Post Reply