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

x
?
Solved

How to find the changed records in dataset?

Posted on 2002-05-16
8
Medium Priority
?
243 Views
Last Modified: 2010-04-04
Hello,

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
    MyDataSet.DisableControls;
    MyDataSet.First;
    while not MyDataSet.Eof do
     begin

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

       MyDataSet.Next;
     end;

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

Thanks,
Pascal
0
Comment
Question by:corpa
[X]
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
8 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 7013410
Hi corpa,

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

------
Igor.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7013422
or use the afterinsert or beforepost-event of the dataset
to supply the fields
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7013551
Interested
0
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!

 
LVL 1

Expert Comment

by:martin_g
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.
0
 

Author Comment

by:corpa
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,
Pascal
0
 
LVL 27

Accepted Solution

by:
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?
0
 
LVL 27

Expert Comment

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

like
procedure TForm1.Table1BeforePost(DataSet: TDataSet);

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

Author Comment

by:corpa
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,
Pascal

0

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