Re: compare two fox tables by Igor
Igor
Tue Dec 30 11:17:04 CST 2003
Hi, reachme_fast@yahoo.com!
You wrote on Mon, 29 Dec 2003 23:36:30 -0800:
rf> I wanted to findout whether user made any changes in a fox
rf> table.
rf> Is there any function to do this ?
No, there can't be such function.
BUT as you know the structures of those tables, you can easily write a
little program that will process both tables and find out the differences.
Just some pieces of code:
SELECT nPK ;
FROM table1, table2 ;
WHERE Table1.nPK = Table2.nPK AND ;
(Table1.nOtherField # Table2.nOtherField OR ;
Table1.cOneMore # Table2.cOneMore OR ...) ;
INTO CURSOR DifferentRecords
SELECT nPK ;
FROM table1 ;
WHERE Table1.nPK NOT IN ;
(SELECT Table2.nPK FROM Table2) ;
INTO CURSOR MissedIn2Records
SELECT nPK ;
FROM table2 ;
WHERE Table2.nPK NOT IN ;
(SELECT Table1.nPK FROM Table1) ;
INTO CURSOR MissedIn1Records
Then you may do all you want with those cursors (they will contain primary
keys of records that are different in both tables, or missed from one of
them) it will also work if you have complex (non single-field Primary Key).
If you don't have PK - then you HAVE to have one - otherwise what are you
doing with relational database :)
P.S. Happy New Year
--
WBR, Igor