Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using objects to capture multiple TRUE condition results
Message
From
03/11/2006 15:46:46
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01166162
Message ID:
01167034
Views:
14
Thanks for your interest; let me try to re-phrase my dilema....

The PROC I've written compares two files - a MASTER table and an UPDATE table. If the value for any field in the UPDATE table is greater than the same field found in MASTER, the value is overwritten, and a record of the change is recorded to another file - RECUPDATE.

MY DILEMA is that instead of writing only one record to RECUPDATE for each record that has been revised in MASTER, a separate record is written to RECUPDATE for each field that is changed in MASTER (ex: if 3 fields were updated in MASTER, 3 separate records are written to RECUPDATE - one for each field changed)

An array called UPDRECS is created, and is used to record the changes to MASTER, and write the records to RECUPDATE

Please see the code below - I've renamed the appropriate files to MASTER and UPDATE, and changed the code to lowercase (for Sergey!!!). Hopefully, the explanation provided above will make it easier for you to offer possible alternatives.

Thanks!
PROC UPDTCAMPAIGN

sele  MASTER
close inde

&& records deleted to to error validations
sele UPDATE
pack 
inde on scid tag scid

sele  MASTER
if reccount() = 0
    appe from UPDATE && if MASTER file is empty, append all records from UPDATE
else
    scatter fields brand,scid,bounces,opens,totalclicks,uniqueclicks,;
    optouts,totalmailed,netmailed name updrecs blank
    store " " to lcupdt
    store 0 to lnupdrec
    1
    scan
       store scid to lnscid
       if seek(lnscid,'UPDATE')

	 if bounces <> UPDATE.bounces
	    repl bounces with UPDATE.bounces
	    scatter fields brand,scid,bounces name updrecs addi
	    do recordupdates
	    lcupdt= "y"
	 else
	    lcupdt= ""
	 endif

          if opens <> UPDATE.opens
	    repl opens with UPDATE.opens
	    scatter fields brand,scid,opens name updrecs addi
	    do recordupdates
	    lcupdt= "y"
          else
	    lcupdt= ""
          endif

       endif

       if !empt(lcupdt)
          lnupdrec= lnupdrec+1
       endif
    endscan

wait wind allt(str(lnupdrec))+" record(s) were updated in the campaign master file" time 1
endif

ENDPROC

********************************************************

PROC RECORDUPDATES

if used('RECUPDATE')
	sele RECUPDATE
else
	use RECUPDATE in 0 excl
	sele RECUPDATE
endif
append blank
gather name updrecs
repl all date with date() for empt(date)
repl all filedate with val(pcfilename) for empt(filedate)

ENDPROC
Gil Robinson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform