Comparing Tables ---- I thought this would be easier

Cool_Dude_eh

New Member
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.
 
how about this -

<snippet>

/* main.p */

/* use diff logical names to tell apart the databases */

connect c:\openedge\wrk\sports2000 -1 -ld dbSource.
connect c:\openedge\wrk2\sports2000 -1 -ld dbTarget.



/* trap any exceptions to make sure disconnect gets done */

do on quit undo, leave
on stop undo, leave
on error undo, leave
on endkey undo, leave:



/* connect cannot be in the same proc accessing the database
* the database has to be connected before the proc is runned */

run compare.p.

end. /* on quit */

disconnect dbSource.
disconnect dbTarget.



/* compare.p */

/* the proc is compiled-on-the-fly
* to compile the proc both source and target sports2000.db have to be connected */

for each dbSource.item
where not can-find( dbTarget.item of dbSource.item )
no-lock:

display dbSource.item with 2 columns 1 down.

end. /* for each item */

</snippet>

hth
 
Back
Top