× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Once you chain, you have the current values, not the values you want to
update. So, simply have the fields be different names. then set master values to
update values..

F MasterFile UF A K Disk
F UpdateFile IF K Disk Prefix(Upd)

D MasterDS E ExtName( MasterFile )

D UpdateDS E ExtName( UpdateFile ) Prefix( Upd )

D UpdateKey LikeRec( UpdateFileR : *Key )


/free
DoU %EoF( UpdateFile) '
Read UpdateFileR ;
If Not %EoF( UpdateFile );
Chain %KDS( UpdateKey ) MasterFileR ;
If Not %Found( MasterFile ) ;
MasterDS = UpdateDS ;
Write MasterFileR ;
Else ;
// Without the following, you are updating the file with
// the original values!!!
If UpdField1 <> Field1 Or UpdField2 <> Field2 Or
UpdField3 <> Field3 Or UpdField4 <> Field4 ;
Field1 = UpdField1 ;

Field2 = UpdField2 ;

Field3 = UpdField3 ;

Field4 = UpdField4 ;
Update MasterFileR ;
EndIf ;
EndIf ;
EndDo ;





In a message dated 11/26/2008 12:39:01 A.M. Jerusalem Standard Time,
newmanas400@xxxxxxxxx writes:

It's been a while since I've done an update program and I know I should know
the answer to this but I don't.

I have a program that reads an update file sequentially and writes to a
master file. After it reads a record from the update file, it chains out to
the master file. If no record was found with the same key it writes the
record to the master file with a WRITE. If a record was found with the same
key, it check 4 other fields to see if this is an exact duplicate. If it is
an exact duplicate it discards the record from the update file. If there
are difference in the 4 fields, it writes the update information by moving
the data to the master file's record and does an UPDAT. I should also
mention I've put code into the program to print the update record and the
master record when it finds one it is going to update.

I ran the program and it shows 200 records updated. I ran it again and it
again shows 200 records updated. It is apparently finding the discrepancies
but not really doing the update.

My question is this: once I find the differences, do I have to CHAIN again
to get the proper record in position to update?

TIA.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.