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

replacing fields 2

Status
Not open for further replies.

maggielady

Technical User
Jan 3, 2003
60
0
0
US
I have two database tables in two different directories, IE: c:\skcms50\family.dbf and c:\datarepair\skcms50\family.dbf. I need to take the family table in c:\datarepair and match it to the family table in c:\skcms50
on famly_id number, then if they match on famly_id, put the fam_hphone value from c:\skcms50\family into c:\datarepair\skcms50\family. Could anyone please help with this? Thanks in advance, you guys and gals are great!!
 
Try something like this:

Code:
set exclusive on
close all
clear
select 0
use c:\skcms50\family.dbf alias source 
select 0
c:\datarepair\skcms50\family.dbf alias target 
index on str(famly_id,12,0) tag famly
select source
go top
m.count = 0
do while .not. eof()
  select target
  seek (str(source.famly_id,12,0))
  if found()
    replace target.fam_hphone with source.fam_hphone
    m.count = m.count +1
    ? target.famly_id
  endif
  select source
  skip
enddo
? "done :"+str( m.count,12,0)+" record(s) changed"

Regards

Griff
Keep [Smile]ing
 
OK, assuming your doing the whole C:\skcms50\family table and both tables have an index on Family_id, this is one of several approaches.

USE C:\DataRepair\skcms50\Family ORDER Family_ID ALIAS Target IN SELECT('Target')
USE C:\skcms50\Family ORDER Family_ID ALIAS Source IN SELECT('Source')
SELECT Source
SET RELATION TO Family_ID INTO Target
SCAN
IF NOT EOF('Target')
REPLACE Target.Fam_HPhone WITH Source.Fam_HPhone
ENDIF
ENDSCAN


Regards,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top