General information
Category:
Coding, syntax & commands
>I am trying to append or update from 1 table to another. They both have the same structure. I cannot make changes to the source table as it beelongs to another company. The source table has no unique field, however, a combination of 3 fields is unique. So I set an index in the target table consisting of these 3 fields. I must evaluate each record in the source table, if it does not exist in the target table I append it. If it does exist, I must see if it has been updated and if so, update the appropriate fields. This is working o.k. but it is very slow as the target table continues to grow and my do while not eof() and seek commands seem to be the only way to make my updates. Any suggestions would be appreciated.
>
>for example the 2 tables have fields A - E.
>None are unique but A + B + C is unique
>
>use table 1
>do while not eof()
> store A + B + C to memvar
> use table 2
> seek A + B + C
> if found()
> if fields D + E dont match
> update
> endif
> else
> append record from table1
> endif
> skip
>enddo
you can also do it with a 3 part SELECT statement
one that fetches records that don't have to get updated in table2
one that retrives the records from table1 that don't exist in table2
and one that retrives the records from table1 where D+E are different and A+B+C are the same
Arnon
Previous
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