Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Very complicated coding...
Message
 
To
09/06/1999 12:40:33
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00227974
Message ID:
00228060
Views:
19
>I will explain as best I can for what we need to program with VFP 6.0. Since I can explain best if I use DO CASE so we can see the point better with little "english".
>
>There are three tables (all in one DBC):
>WORKPO.dbf (and field "po" is CDXed) "working table"
>HISTPO.dbf (and field "po" is CDXed) "history table"
>DELEPO.dbf (just in case we need to look back...) "deleted data"
>
>What happens is we import data into WORKPO.dbf and then see if there is a match in HISTPO.dbf. It goes like this:
>
>SEEK or SCAN or LOCATE for WORKPO.po = HISTPPO.po
>DO CASE
> IF FOUND()
> SELECT WORKPO
> COUNT FOR how many "po" TO po1
> SELECT HISTPO
> COUNT FOR how many "po" TO po2
> DO CASE
> CASE po1 <> po2
> remove all matched "po" to DELEPO
> APPEND new matched "po" into HISTPO
> CASE po1 = po1 AND there are only one "po" in both tables
> check all the fields of that "po"
> IF all fields matched
> leave it alone and EXIT/LOOP to the next record in WORKPO
> ELSE
> remove matched "po" from HISTPO to DELEPO
> APPEND new matched "po" (new updated data)
> ENDIF
> CASE po1 = po2 AND there are more than one "po" on both tables
> (or OTHERWISE)
> ******************************************
> ** this is where I need to figure out!! **
> ******************************************
> say suppose there is 4 "po" on both tables, I need to check
>record by record, and once a record matches (all fields), I need to MARK that record so I don't check that same record again with the next
>matching "po", did you follow this?
>
>Chuck


why not use views instead of counts:

*define parameter used in views
vp_po = pono

if ! used('lv_WORKPO')
use lv_workpo in 0 nodata
endif

index on ponum tag ponum

if ! used('lv_histPO')
use lv_histpo in 0 nodata
endif


sele lv_workpo
index on ponum tag ponum
requery()

sele lv_histpo
index on ponum tag ponum
requery()

Now you only have easy to use cursosrs that can manipulate the data in the actual tables if you set the dbsetprop()'s properly.

I get confused as to why you could have current and history data and a dupe of a po without a field in workpo like CURRENT. I have SBT and they use the same method of a current and history table too.

Another way to to UNION the two tables together but watch out for dropped dupes! UNION will do that all by itself.



But getting back to the 2 views above.

Sele lv_workpo
scan
cponum=ponum
sele lv_histpo
seek(cponum)
if found()
sele workpo
dele
endif
sele lv_workpo
scan
Previous
Reply
Map
View

Click here to load this message in the networking platform