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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare values of first and second entry

Status
Not open for further replies.

namax

Technical User
May 22, 2011
19
PG
I'm sorry for not making my problem clear to you.

What I meant was this,I want double entries to be done for the questionairre forms.there will be two data entry clerks. one will do the first entry of forms and another will do the second entry of the same forms.so that means there will be two tables,one for the first entry and the other would be for the second entry.

so how would i compare the values of these two tables and find differences of values of respective fields and make corrections to them in the master table.for instance,if a field is 'sex' and the value in the physical form is male but the first entry value is female and the second entry value is male ie typing error,hence the code i would write to pick up this difference is the problem that i am trying to solve.

Hope I made myself clear with this post.

Thankyou very much in advance for your time.

 
From the situation let me assume the one tables are called questionnairremaster.dbf and questionnairreslave.dbf, then what you need anyway is some common value of both records to compare. Either the forms have some ID or barcode printed on them or the first clerk writes some identifier on it the second clerk also enters. If that is differing you have no chance to compare.

I make the assumption the clerks not necessarily input the data in the exact same order, so you can't be sure you'd always need to compare the same record numbers in table1 or 2.

If you don't have such an identifier you better introduce it, or this is getting a worse problem.It's not impossible, as you can make it a best fit match, but you see this is a harder problem.

Assumed there is something to rely on the worst thing happening is there is no match in that, but that should be seldom and is easily identified with the first two Selects in the following code.

Code:
* finding corresponding form entries by their ID
select * from questionnairremaster where ID not in (select ID from questionnairreslave) into curMissingSlaverecord

select * from questionnairreslave where ID not in (select ID from questionnairremaster) into curMissingMasterrecord

Select master.id, Cast(Sys(2017,"",0,3) AS C(10)) As cChecksumMaster, slave.cChecksumSlave;
From questionnairremaster master ;
inner join ( ;
Select id, Cast(Sys(2017,"",0,3) AS C(10)) As cChecksumSlave;
From questionnairreslave) slave ;
On master.ID = slave.ID;
Having cChecksumMaster<>cChecksumSlave

And the third SQL Select is the one finding forms, which should be identical, but aren't, by comparing their checksum.

nce you have their IDs you can compare each individual field to find the difference, you could use AFIELDS, if the fields don't stay the same and you still only want to program this once and for all.

Bye, Olaf.
 
Sorry, each "into" should be "into CURSOR" and the last select also needs an INTO CURSOR curQuestionnairreMismatches

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top