(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.
tomr
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 20.03.2017, 11:20

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

Postby tomr » 20.03.2017, 11:30

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
Gold Boarder
Gold Boarder
Posts: 572
Joined: 17.01.2011, 14:17

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

Postby marsupilami » 20.03.2017, 15:15

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


Return to “ZeosLib 7.1 stable Forum”

Who is online

Users browsing this forum: No registered users and 1 guest