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

Database Question

Status
Not open for further replies.

PremiumL

MIS
Nov 3, 2004
10
US
I have 2 databases.

Mail.dbf
Master.dbf

Basically, both of these databases have the same layout. They both have a field called contact (which is filled with people's names). The contact field in mail.dbf is blank. I need a program that will match up the phone numbers in both databases (the field is called phone), and when there is a match, I want the program to copy the contact field from master.dbf to mail.dbf. Thanks for your help.

Thanks,

Jarrett
 
I'm a newbie to Foxdos. What commands do I need to put in the program in order to do that?

Thanks for your help,

Jarrett
 
Close Data
use master
select 0
use mail
scan
select master
if locate for (master.phone = mail.phone) and empty(master.phone)
select mail
replace contact with master.contact
endif
select mail
endscan
close data
 
Skarcrow,
The statement:
Code:
if locate for (master.phone = mail.phone) and empty(master.phone)
isn't valid.

Try this instead:
Code:
Close Data
use master
select 0
use mail
scan
    select master
    locate for (master.phone = mail.phone) ;
        and empty(master.phone)
    if found()
       select mail
       replace contact with master.contact
    endif
    select mail
endscan
close data

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
The above code may work but wouldn't be appropriate if the files are very large. Here is the same thing in high performance code that makes full use of the Fox relational database:
Code:
set talk on
CLOS DATA
USE MASTER
INDEX ON PHONE UNIQUE COMPACT TO TEMP
SELE 0
USE MAIL
SET RELA TO PHONE INTO MASTER
REPL FOR NOT EOF("MASTER") CONTACT WITH MASTER.CONTACT
CLOS DATA
ERASE ("TEMP.IDX")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top