Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How to find the changed records in dataset?

Posted on 2002-05-16
Medium Priority
Last Modified: 2010-04-04

I'm using cached updates and in some cases there are Null values in some fields. Butt my database can not handle
these values. I would like to fill these fields with an empty string (or one space) before they are updated.
How can I see if a record in a dataset has been changed?
I would like to use something as follows:

 if MyDataSet.ChangeCount > 0 then
    while not MyDataSet.Eof do

//  Here I would like to know if this particular record
//  has been changed.
//  if changed then field := ' ';


Is this the proper way to do this?
I tryed OnReconcile but there I can't change my fieldvalue anymore.

Question by:corpa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 7013410
Hi corpa,

why do not let SQL server do it for you?
Declare default value for field.

LVL 27

Expert Comment

ID: 7013422
or use the afterinsert or beforepost-event of the dataset
to supply the fields

Expert Comment

ID: 7013551
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 7013751
How do the Null values get inserted?  It might be better to capture and change them when the record is first created or when the recored is edited by the user rather than wait for the cached update.  You can use the  record's OnValidate or OnPost event for this.

Another way is to enforce constraints on the individual fields. You would use  the field's DefaultExpression property to enter a default value such as ' ' or '0'.  You could also use the CustomExpression property to enforce a condition such as if  VALUE=NULL  then VALUE:= ' ';  These constraintsare applied when the record is posted and take precedence over server-side constraints.

Author Comment

ID: 7014792
Hi all,
First let me explain a little bit more about the database.
It's a real time object oriented database called InfoPlus21 by the American company AspenTech.
There are tables defined called selectorDef wich contain discrete values. These tables can be used as a lookuptable, but wont accept empty entries like space. It converts them back to a Null value. And there is my problem. I use these tables in a lookupfield in a dbgrid.
The selected value gets written in another (invisible) field from another table in that database.
So if I select the empty field in the lookuptable a Null gets into my actual field and an error occurs when I call ApplyUpdate. So my idea was before I call ApplyUpdate I go through the dataset and only look in the changed records if there's a Null in my particular field and set it to a space, because at that point and in that field the space will be accepted.
I hope I didn't lost everyone by my explanation but this is somewhat my situation.

Thanks for the cooperation so far guys,
LVL 27

Accepted Solution

kretzschmar earned 400 total points
ID: 7014813
i don't know anything about InfoPlus21,
is there no way to use a query as lookup-dataset
where these empty entries are excluded with usage of a where-clause?
LVL 27

Expert Comment

ID: 7014821
another thing is allways to use the beforepost event of the target dataset to supply such null-fields with a value

procedure TForm1.Table1BeforePost(DataSet: TDataSet);

if table1.fieldbyname('fieldname').IsNull then
  table1.fieldbyname('fieldname').AsString := 'Empty'; //or whatever

Author Comment

ID: 7015707
Hi kretzschmar,

My problem is solved thanks to you.
I actually allready did use a query as lookup-dataset,
but I never got the idea to remove the Null-values in
this dataset.
So the points go to you,
Thanks again mate,


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Screencast - Getting to Know the Pipeline
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question