Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing tables ---- I thought this would be easy

Status
Not open for further replies.

CoolDudeeh

IS-IT--Management
Oct 21, 2003
21
US
I am trying to compare records in 2 databases.
The table names and fields names are the same in both.
For example.
Lets say db1 and db2.
I want to go through db1, table1 and find the same record in db2 table1.
If the record is not found in db2, I want the record used to find it displayed.
I thought something like this would work.

for each db1.table1.
find db2.table1 where db2.table1.key = db1.table1.key.
if not avail(db2.table1) then display db1.table1.key.

Can anyone give me some help here as I am not familiar with working with two identical db's.

Thank you in advance.
 
What Progress errors are you getting?

You should use the NO-ERROR phrase to suppress the default Progress error message for RECORD NOT AVAILABLE, and the record AVAILABLE syntax does not use parentheses:

for each db1.table1:
find db2.table1 where db2.table1.key = db1.table1.key
NO-LOCK NO-ERROR.
if not available db2.table1 then display db1.table1.key.
end.

If your record key is not UNIQUE, you should use FIND FIRST.
 
For completeness you should also run your test the other way round to pick up records that are in db2 but not in db1.

And use NO-LOCK on your FOR EACHes and FINDs.

Cheers, Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top