General information
Category:
Coding, syntax & commands
please help i can't seem to get this code right,
********
Use F:\TEMP\DATA\CUSTOMERS IN 0 ORDER TAG LASTNAME ALIAS MAIN EXCLU
Use F:\TEMP\IMPORT\CUSTOMERS IN 0 ORDER TAG LASTNAME ALIAS IMP_MAIN EXCLU
Select IMP_MAIN
Scan
Scatter to Aimp_rec memvar
Select MAIN
Seek(LASTNAME)
If found()
Scatter to Amain_rec memvar
If Changes(@Amain_rec, @Aimp_rec, 37)
Gather from Aimp_rec memvar
Endif
Else
Append Blank
Gather from Aimp_rec memvar
Endif
Endscan
Close TABLES ALL
Function Changes
Parameters Amain_rec, Aimp_rec, nlen
For x = 1 to nlen
If Amain_rec(x) != Aimp_rec(x)
Return .T.
Endif
Next
Return .F.
*********
I have 2 tables I am comparing and I want to add a record to the main table is one doesn’t exist, from the import table, or if one does exist I want to overwrite it if it's changed. The problem I get is the main table only adds the last record from the import table. I think there is something wrong with the way I seek for the record or append it. My table structure has a field named "LASTNAME" that for now I am searching on but will change to a customer id number in production. Thanks in advance.
Bill
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only