Comparing two databases. 
Author Message
 Comparing two databases.

I am an inexperienced Clarion user, and have for this reason limited or non
experience of importing, exporting external databases.

I have two databases wich is in ASCII form, which I want to be compared.

Call the databases A and B, and they both contains addresses. Database A
contains approx 11000 records, and Database B contains approx 7000 records.
Most of the records in database B is in Database A. I want to have a report
or a new database showing the diffrence, i.e. the 4000  missing.

I pictured that a code / programme  opened database A + B, compared company
name and Zip code, and added all all records which was found not to be in
database B over to a new database C.

Can anyone help?



Mon, 28 Jan 2002 03:00:00 GMT  
 Comparing two databases.
Hi Eric,

Need more info about which version of Clarion, which file format you want
the end result to be in etc...

You can probably do it by using  "unique two part keys".  Or maybe one of
the Import/Export 3rd party utilities.

----------
Health, happiness, prosperity.
Earl
www.kwiksystems.com



Quote:
> I am an inexperienced Clarion user, and have for this reason limited or
non
> experience of importing, exporting external databases.

> I have two databases wich is in ASCII form, which I want to be compared.

> Call the databases A and B, and they both contains addresses. Database A
> contains approx 11000 records, and Database B contains approx 7000
records.
> Most of the records in database B is in Database A. I want to have a
report
> or a new database showing the diffrence, i.e. the 4000  missing.

> I pictured that a code / programme  opened database A + B, compared
company
> name and Zip code, and added all all records which was found not to be in
> database B over to a new database C.

> Can anyone help?



Mon, 28 Jan 2002 03:00:00 GMT  
 Comparing two databases.
Hi Earl,

Quote:
>Need more info about which version of Clarion

I have Clarion Professional Edition Ver. 5 ( and Clarion Professional
Developer 2.1 which I used many years back )

Quote:
>which file format you want

Preferly in a ASCII format, but the file format is of less importance.

---

Erik



Mon, 28 Jan 2002 03:00:00 GMT  
 Comparing two databases.
Erik,
   Create a clarion file with Co Name & Co Zip as a Unique key
   Loop through Ascii file A adding records then Loop though file B
   adding records, the unique key will give you an error code of 40
   (Dup Key Error) so you will end up with what you want.
   You could hand code a report printing the file name and record
   information by using if errorcode() = 40; Print(Detail) all in one pass.

HTH

Bill Rollins



Quote:
> I am an inexperienced Clarion user, and have for this reason limited or
non
> experience of importing, exporting external databases.

> I have two databases wich is in ASCII form, which I want to be compared.

> Call the databases A and B, and they both contains addresses. Database A
> contains approx 11000 records, and Database B contains approx 7000
records.
> Most of the records in database B is in Database A. I want to have a
report
> or a new database showing the diffrence, i.e. the 4000  missing.

> I pictured that a code / programme  opened database A + B, compared
company
> name and Zip code, and added all all records which was found not to be in
> database B over to a new database C.

> Can anyone help?



Mon, 28 Jan 2002 03:00:00 GMT  
 Comparing two databases.
Erik,

You're describing a classic two way merge.  

You need to do a "priming" read from A and one from B.  Next compare the
"keys" from A with the keys from B.  If they're the same, move on to the
next pair.  

If A is lower (or B is higher), you've detected a mismatch.  Write the
record to the file (or whatever is appropriate for your problem) and
read from the lower keyed file and try again.

You'll need the following structure:

LOOP until done
  IF A-key = B-key
     = Keys Match =
    IF A-key = '****EOF****'
       done = true
    END

    READ A-file
    READ B-file

  ELSIF A-key < B-Key
     = A is lower; do something =
    READ A-file

  ELSE
     = B is lower; do something =
     READ B-File
  END
END

READ A-File routine
  <whatever>
  IF eof condition
     A-key = '****EOF****'
  END

READ B-File routine
  <whatever>
  IF eof condition
     B-key = '****EOF****'
  END

Be sure to handle the EOF condition.  I typically handle it by using a
funky "last record" value in my read routines (****EOF**** in above
example) and take care of that in the "equals" logic just to make the
logic cleaner.  I've also used EOF flags but then you get into compound
IF logic which quickly gets very messy.

HTH

Al



Tue, 29 Jan 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how to compare two columns in two files?

2. reading two files and comparing them

3. comparing two files

4. Comparing fields in a two records

5. comparing two arrays with same length

6. comparing two dbfs record by record

7. Comparing two commercial versions of FORTH

8. Two diferent definitions - comparing resources (Haskell)

9. compare two numbers with one string (true/false) output

10. Can LabView compare two curves?

11. Comparing Power (EXpressivity ?) of Two Langages

12. Comparing two arrays

 

 
Powered by phpBB® Forum Software