Board index » delphi » TField.OldValue, TField.NewValue ?

TField.OldValue, TField.NewValue ?


2003-09-09 09:30:41 AM
delphi235
Hi,
I have problem in a maintenance program. The problem is caused by the
attribute of TField.OldValue and TField.NewValue.
I am using IBX 6.05, Inquiry, DataProvider and ClientDataSet for the
maintenance program. I do the following editing on a data record.
- In BeforePost event (Insert a Record). It seems OK, I input 'A' in a
Field named DATAFLD.
- DATAFLD.OldValue is NULL
- DATAFLD.CurValue is NULL
- DATAFLD.NewValue is 'A'
- In BeforePost event (Edit the Record again). It also seems OK, I
change 'B' in the DATAFLD.
- DATAFLD.OldValue is 'A'
- DATAFLD.CurValue is NULL
- DATAFLD.NewValue is 'B'
- BUT, in BeforePost event (Edit the Record again). I change 'C' in the
DATAFLD.
- DATAFLD.OldValue is 'A'
- DATAFLD.CurValue is NULL
- DATAFLD.NewValue is 'C'
The problem is that when I edit the record second or later time, the
DATAFLD.OldValue is still stored in the value same at the Insert record
time. Why ?
Another question is that why the value of CurValue is always stored the
NULL value.
Would you let me know the mechanism of OldValue, CurValue and NewValue ?
Regards,
Nelson.
 
 

Re:TField.OldValue, TField.NewValue ?

On Tue, 09 Sep 2003 09:30:41 +0800, Nelson Chui
<XXXX@XXXXX.COM>writes:
Quote
The problem is that when I edit the record second or later time, the
DATAFLD.OldValue is still stored in the value same at the Insert record
time. Why ?
The ClientDataSet needs to know two things for a record you edit.
1) The original values read from the database. The CDS needs this
information to find the record in the database when you try to update
it.
2) The current value of the fields that have been changed.
That is all the information that is stored. If you edit a record six
times the CDS does not maintain six versions of the record. All it
maintains is the original values and the new values.
 

Re:TField.OldValue, TField.NewValue ?

Hi, Bill
Firstly, thank you for your reply !!!
But I have still a question about the function the TField.CurValue. I
try a test, the TField.CurValue is always to NULL on debugging in
OnBeforePost Event.
Would you let me know about that ?
Regards,
Nelson.
 

Re:TField.OldValue, TField.NewValue ?

On Wed, 10 Sep 2003 15:36:38 +0800, Nelson Chui
<XXXX@XXXXX.COM>writes:
Quote
But I have still a question about the function the TField.CurValue. I
try a test, the TField.CurValue is always to NULL on debugging in
OnBeforePost Event.
The record has not been changed until you post. Until you call post
the changes exist in a temporary buffer in memory, not in the dataset.
 

Re:TField.OldValue, TField.NewValue ?

Hi Nelson,
this record is already in database or is a new record ?
Fabio Gibon
"Nelson Chui" <XXXX@XXXXX.COM>writes
Quote
Hi, Bill

Firstly, thank you for your reply !!!

But I have still a question about the function the TField.CurValue. I
try a test, the TField.CurValue is always to NULL on debugging in
OnBeforePost Event.

Would you let me know about that ?

Regards,
Nelson.

 

Re:TField.OldValue, TField.NewValue ?

Hi, Fabio:
This CientDataSet record is posted, but is not call ApplyUpated and
Commit yet.
Thank for you reply !
Regards,
Nelson.
Fabio Gibon writes:
Quote
Hi Nelson,
this record is already in database or is a new record ?

Fabio Gibon

"Nelson Chui" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...

>Hi, Bill
>
>Firstly, thank you for your reply !!!
>
>But I have still a question about the function the TField.CurValue. I
>try a test, the TField.CurValue is always to NULL on debugging in
>OnBeforePost Event.
>
>Would you let me know about that ?
>
>Regards,
>Nelson.
>



 

Re:TField.OldValue, TField.NewValue ?

Nelson,
CurValue is a value already in database, when you don't applyupdate curvalue
is null... Did you test using a already updated record ?
regards,
Fabio Gibon
"Nelson Chui" <XXXX@XXXXX.COM>writes
Quote
Hi, Fabio:

This CientDataSet record is posted, but is not call ApplyUpated and
Commit yet.

Thank for you reply !

Regards,
Nelson.


Fabio Gibon writes:
>Hi Nelson,
>this record is already in database or is a new record ?
>
>Fabio Gibon
>
>"Nelson Chui" <XXXX@XXXXX.COM>writes
>news:XXXX@XXXXX.COM...
>
>>Hi, Bill
>>
>>Firstly, thank you for your reply !!!
>>
>>But I have still a question about the function the TField.CurValue. I
>>try a test, the TField.CurValue is always to NULL on debugging in
>>OnBeforePost Event.
>>
>>Would you let me know about that ?
>>
>>Regards,
>>Nelson.
>>
>
>
>

 

Re:TField.OldValue, TField.NewValue ?

Hi, Fabio
Thank you for your reply !
But, What is the difference between TField.OldValue and TField.CurValue ?
Regards,
Nelson.
Fabio Gibon writes:
Quote
Nelson,

CurValue is a value already in database, when you don't applyupdate curvalue
is null... Did you test using a already updated record ?

regards,
Fabio Gibon

"Nelson Chui" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...

>Hi, Fabio:
>
>This CientDataSet record is posted, but is not call ApplyUpated and
>Commit yet.
>
>Thank for you reply !
>
>Regards,
>Nelson.
>
>
>Fabio Gibon writes:
>
>>Hi Nelson,
>>this record is already in database or is a new record ?
>>
>>Fabio Gibon
>>
>>"Nelson Chui" <XXXX@XXXXX.COM>writes
>>news:XXXX@XXXXX.COM...
>>
>>
>>>Hi, Bill
>>>
>>>Firstly, thank you for your reply !!!
>>>
>>>But I have still a question about the function the TField.CurValue. I
>>>try a test, the TField.CurValue is always to NULL on debugging in
>>>OnBeforePost Event.
>>>
>>>Would you let me know about that ?
>>>
>>>Regards,
>>>Nelson.
>>>
>>
>>
>>


 

Re:TField.OldValue, TField.NewValue ?

Nelson,
see help information below...
quoted
CurValue
Represents the current value of the field component "including changes made
by other users of the database".
property CurValue: Variant;
Description
Use CurValue to examine the value of a field when a problem occurs in
posting a value to the database using a provider. If the current field value
is causing a problem, such as a key violation, when posting the value, an
event is generated to allow applications to respond to the problem. Client
datasets generate an OnReconcileError event. On the server side, provider
components generate an OnUpdateError event. In the event handler, NewValue
is the unposted value that caused the problem, OldValue is the value that
was originally assigned to the field before any edits were made, and
CurValue is the value that is currently assigned to the field. ***CurValue
may differ from OldValue if another user changed the value of the field
after OldValue was read.***
Note: CurValue is only supported when the dataset is a TClientDataSet. In
the provider's OnUpdateError event, a temporary client dataset containing
fields with a CurValue property is passed to the event handler.
unquoted
"Nelson Chui" <XXXX@XXXXX.COM>writes
Quote
Hi, Fabio

Thank you for your reply !

But, What is the difference between TField.OldValue and TField.CurValue ?

Regards,
Nelson.

Fabio Gibon writes:
>Nelson,
>
>CurValue is a value already in database, when you don't applyupdate
curvalue
>is null... Did you test using a already updated record ?
>
>regards,
>Fabio Gibon
>
>"Nelson Chui" <XXXX@XXXXX.COM>writes
>news:XXXX@XXXXX.COM...
>
>>Hi, Fabio:
>>
>>This CientDataSet record is posted, but is not call ApplyUpated and
>>Commit yet.
>>
>>Thank for you reply !
>>
>>Regards,
>>Nelson.
>>
>>
>>Fabio Gibon writes:
>>
>>>Hi Nelson,
>>>this record is already in database or is a new record ?
>>>
>>>Fabio Gibon
>>>
>>>"Nelson Chui" <XXXX@XXXXX.COM>writes
>>>news:XXXX@XXXXX.COM...
>>>
>>>
>>>>Hi, Bill
>>>>
>>>>Firstly, thank you for your reply !!!
>>>>
>>>>But I have still a question about the function the TField.CurValue. I
>>>>try a test, the TField.CurValue is always to NULL on debugging in
>>>>OnBeforePost Event.
>>>>
>>>>Would you let me know about that ?
>>>>
>>>>Regards,
>>>>Nelson.
>>>>
>>>
>>>
>>>
>
>

 

Re:TField.OldValue, TField.NewValue ?

TField.OldValue is the value originally read from the DB.
TField.NewValue is the value the DB is to be updated to.
TField.CurValue only has a non NULL value *after* an update failure,
where the failure was due to a no record found type error; e.g.
'Record not found or changed by another user'. MIDAS then obtains and
returns the current value from the DB as TField.CurValue.