Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Most effective way to compare 2 collections
Message
From
15/07/2003 08:27:48
 
 
To
15/07/2003 06:53:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00810098
Message ID:
00810150
Views:
8
Hi,
In fact, I am using collections to store list of my item's prices.
Once user press save button, my application will loop thru the collection to get the prices and save to table.

Since, it allow multiple changes in a save operation, I choose "delete and insert" way to save them to table. IOW, I will delete all relevant record, then re-insert the latest list one by one.

However, I feel that it really wasting spaces, it may not applicable in my application design in certain situation. Therefore, I am looking for the way of "Update" type which, I will have 1 copy of collection for manipulation (WK), and 1 copy for comparation (COPY)(just like VFP view update using SQL Update).

At this moment, what I think to acheive it as below:
1. Once user press save button, my application will check for any "deletion", "new item", and "changes" to the prices stored in collection.
2. To detect deletetion, loop thru each item in COPY collection and check any of them is not exist in WK collection, if so delete the record from table.
3. To detect new item - loop thru WK collection and check any of them not exist in COPY collection, if so, add to table.
4. To detech changes, - loop thru WK collection and check existence in COPY collection, if so, copy content ..

From what mentioned above, it may take quite long time to compare. Hereby, I would like to know, are there any better and effective way to do this?

Please advise
Thank you
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform