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!

set relation to and replace

Status
Not open for further replies.
Jul 7, 2003
95
0
0
US
my problem...

*tank1 has 80,000 and has field dr1 (a date field) populated with no date.
*tank2 has 10 records and the exact record exists in table tank2 but field dr1 has no date populated.

*for some reason.... this has me stumped.. it is cause its a date field? or is it cause I dont have a where clause or something?

CLOSE ALL
SELE 1
USE tank1 alias master
&&master file with 80,000 recored
SELE 2
USE tank2 alias newfile
&&temp file with 10 records
SET SAFETY OFF
INDEX ON id TAG idd
SET SAFETY ON
Clear
SELE 1
SET RELATION TO idd INTO B
replace all a.dr1 with b.dr1

&&dr1 is a date fields that must be transfered to tank1, the larger file

My goal is to have tank1 date field dr1 replaced with tank2 dr1 field.

This seems to work for text fields.. not date fields.. do I need to convert to dtoc() or something?

Thanks in Advance for any help.. you guys are always great for us wannabe geeks.....
 
What's failing? Is there error with the replace itself or is it just not replacing?
If it is just not replacing, it is probably because the relation isn't working right. If the tank2 file is at EOF(), the replace won't happen.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
>>SET RELATION TO idd INTO B

Do you have a field called "idd" or was this just a typo? I noticed that you named your index tag "idd", but you need to reference the actual field name for the relation.
 
I have tried everything I know... the fields in tank2 simply will not populate. I am seriously stumped.

Any ideas?
 
Well, there is something wrong with the relation. I'm not exactly sure what since I can't see it in action, but try something like this instead:
Code:
CLOSE ALL
SELE 1
USE tank1 alias master
&&master file with 80,000 recored
SELE 2
USE tank2 alias newfile
&&temp file with 10 records
SET SAFETY OFF
INDEX ON id TAG idd
SET SAFETY ON
Clear

*SELE 1
*SET RELATION TO idd INTO B
*replace all a.dr1 with b.dr1 

SELECT master
SCAN
   IF SEEK(master.id, 'newfile')
      REPLACE master.dr1 WITH newfile.dr1
   ENDIF
ENDSCAN
You will at least be able to step though the code and look at the records when the seek() happens.
You can also place both tables on a record you know should match, and in the command window try this:
?tank1.id == tank2.id
It may render a clue.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Funny.... I had to put in a . . . . Do while not .t.

It worked.. hmmmmmm
 
Sorry it took so long to get back to you.. a bit of a vacation.. however... it did not create an endless loop.. it SIMPLY worked.... if you want to see the portion of the code I am talking about, let me know and I will post it.

Confusion sometimes works best!
 
Actually, I wasn't paying attention.

DO WHILE NOT .T.

Will bypass whatever section of code is contained within the do while loop. So whatever you are trying to do, that section of code is getting ignored.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top