Subject Re: [IBO] Slow Posting becouse of calculated fields
Author Geoff Worboys
> Happy Christmas to everyone & Loves from Turkey...

And to you.

> My table includes 5 calculated field and I have this function
> what I don't under stand is why TIB_Query runs this function 14
> times when posting, any reason? any solution? are welcome

By default TIB_Query calls OnCalculateField once for each calculated
field in the dataset. Each call comes with the AField parameter set to
the particular calculated column instance. The usual arrangement in
OnCalculateField then becomes something like...

with AField do
if FieldName = 'STYLE' then
<do the calculation>

The result of this is that your function (with 5 calculated fields)
will be called 5 times for every row. In my brief experiment here I
found that posting resulted in two lots of calculatingfields being
done (I did not check but this is presumably one just before posting
and one on the refresh of the row after post).

There is a recently introduced property on TIB_Query called
CalculateAllFields, when this is set to true then OnCalculateField is
only called once per requirement, with the AField parameter set to
nil. In this instance the function would be setup as you have it, to
calculate all calculated fields in a single call.


Geoff Worboys
Telesis Computing