Board index » off-topic » ClientDataSet InternalCalc not fired for all records

ClientDataSet InternalCalc not fired for all records


2006-05-22 10:30:58 PM
off-topic18
I have added a InternalCalc Field to a ClientDataSet and I'm
calculating it on the OnCalcFields like this:
if DataSet.State = dsInternalCalc then
begin
cdsLancVALORFINAL.AsCurrency := cdsLancVALOR.AsCurrency +
cdsLancACRESCIMO.AsCurrency;
end;
My problem is that the event is not getting fired with the State =
dsInternalCalc for all records. So some of the records are not
calculated.
The records that is not calculated because the State is dsCalcFields,
and not dsInternalCalc.
I'm not able to find the problem. Any ideas?
Thanks!
--
Erick Sasse
 
 

Re:ClientDataSet InternalCalc not fired for all records

I am not sure that I understand the problem. Since the value of an
internal calculated field is stored as part of each row it only needs
to be calculated when one of the values used in the calculation changes
for a particular row. An internal calculated field is not supposed to
recalculate each time a row is accessed.
--
Bill Todd (TeamB)
 

Re:ClientDataSet InternalCalc not fired for all records

Bill Todd wrote:
Quote
I am not sure that I understand the problem. Since the value of an
internal calculated field is stored as part of each row it only needs
to be calculated when one of the values used in the calculation
changes for a particular row. An internal calculated field is not
supposed to recalculate each time a row is accessed.
Ok, so where is the right place to calculate the internal calculated
field? Shouldn't I use the OnCalcFields and check if the DataSet.State
is equal to dsInternalCalc?
--
Erick Sasse
 

{smallsort}

Re:ClientDataSet InternalCalc not fired for all records

Erick Sasse wrote:
Quote
Ok, so where is the right place to calculate the internal calculated
field? Shouldn't I use the OnCalcFields and check if the DataSet.State
is equal to dsInternalCalc?
Yes.
Perhaps it would help if you explain what is not working right for you.
--
Bill Todd (TeamB)
 

Re:ClientDataSet InternalCalc not fired for all records

Bill Todd wrote:
Quote
Perhaps it would help if you explain what is not working right for
you.
Well, that's what I'm trying to do, so let me try to be more clear.
The event OnCalcFields is fired for all records, but for most of them,
the DataSet.State is dsCalcFields and not dsInternalCalc, so a lot of
records are not calculated.
I mean for most of records, the OnCalcFields is never fired with
DataSet.State equal to dsInternalCalc.
I hope I was more clear now.
Thanks for your time.
--
Erick Sasse
 

Re:ClientDataSet InternalCalc not fired for all records

So some records have the correct value in the internal calculated field
and the other records have null for the value of the internal
calculated field. Is that correct?
--
Bill Todd (TeamB)
 

Re:ClientDataSet InternalCalc not fired for all records

Bill Todd wrote:
Quote
So some records have the correct value in the internal calculated
field and the other records have null for the value of the internal
calculated field. Is that correct?
Yes.
--
Erick Sasse
 

Re:ClientDataSet InternalCalc not fired for all records

Erick Sasse wrote:
Quote
Bill Todd wrote:

>So some records have the correct value in the internal calculated
>field and the other records have null for the value of the internal
>calculated field. Is that correct?

Yes.
Since this is happening with D2006 you should file a bug report in QC
if you have a simple test case.
The only workaround that I can suggest is to recalculate the field
whenever the OnCalcFields event fires.
--
Bill Todd (TeamB)
 

Re:ClientDataSet InternalCalc not fired for all records

Bill Todd wrote:
Quote
Since this is happening with D2006 you should file a bug report in QC
if you have a simple test case.
Ok, I'll try.
Quote
The only workaround that I can suggest is to recalculate the field
whenever the OnCalcFields event fires.
Thanks.
--
Erick Sasse
 

Re:ClientDataSet InternalCalc not fired for all records

On 22 May 2006 14:34:09 -0700, "Erick Sasse"
< XXXX@XXXXX.COM >wrote:
Quote
>Since this is happening with D2006 you should file a bug report in QC
>if you have a simple test case.
cool! that's exactly the problem I encountered just yesterday.
unfortunately it was the first time I tried to create InternalCalc
field using bds2006 (in bcb5 I used all these years before everything
was just fine)
for me State is _never_ dsInternalCalc within OnCalcFields event
handler. it looks like there's regression bug within latest midas.dll
so CalcFieldsCallBack never gets called (?)
Quote
>The only workaround that I can suggest is to recalculate the field
>whenever the OnCalcFields event fires.
that was the first thing I tried but unfortunately in some cases (when
I have several cloned datasets) it throws 'Dataset not in edit or
insert state'
another bug I encountered in bds related to wrong handling of some
Constraints in CDS so I had to remove them and write code within
BeforePost handler
--
Vladimir Ulchenko aka vavan
 

Re:ClientDataSet InternalCalc not fired for all records

vavan wrote:
Quote
cool! that's exactly the problem I encountered just yesterday.
unfortunately it was the first time I tried to create InternalCalc
field using bds2006 (in bcb5 I used all these years before everything
was just fine)
Actually I'm having this problem with D7.
--
Erick Sasse