Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why these two commands will give different results
Message
From
05/12/2006 05:00:56
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01174441
Message ID:
01174856
Views:
7
Naomi,
>I put set order to and got
>
>Found a mismatch on I909648COL cRate = 0 laArr[1]= 0.094859333
...
>Found a mismatch on I518767COL cRate = 0 laArr[1]= 0.100000000
>
>This is strange since these Inv_No + Salesman do not exist in the table. I've tried to do select and seek in command window and they returned empty results.
>
>Somehow SELECT SUM() finds wrong records. I re-built index Com_Inv earlier today by deleting it first.

I still presume my first guess was correct<g>. To verify (replace file_log with your personal log call):
SELECT Comision
lnRecno = RECNO()  && Dunno what for

local laArrChk [1], lnRun, lnCheck, llSeekfnd, lcMess
lnCheck = 10

SELECT SUM(rate*SHARE/10000) AS crate, count(*) ;
                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
              	FROM comision INTO ARRAY laArr

if laArr[1,2]>0
   if laArr[1,2]<=6000
      SELECT ;
             Recno(), inv_no, salesman, rate, SHARE ;
             , inv_no+salesman, m.ccinv + m.Slsman ;
             , Len(inv_no+salesman), Len(m.ccinv + m.Slsman) ;
                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
              	FROM comision INTO ARRAY laArrChk
     assert _tally=laArr[1,2] 
   else
      SELECT top m.lnCheck ;
             Recno(), inv_no, salesman, rate, SHARE ;
             , inv_no+salesman, m.ccinv + m.Slsman ;
             , Len(inv_no+salesman), Len(m.ccinv + m.Slsman) ;
                WHERE inv_no+salesman = m.ccinv + m.Slsman ;
              	FROM comision INTO ARRAY laArrChk
   endif
endif

SELECT Comision
SET ORDER TO com_inv IN comision
IF SEEK(m.ccinv + m.Slsman)                	
	SUM (rate*SHARE/10000) TO cRate WHILE inv_no+salesman = m.ccinv + m.Slsman
        llSeekfnd = .t.
ELSE
	cRate = 0
endif		

lcRate = EVL(laArr[1],0)
IF NOT m.cRate = m.lcRate
 	=MESSAGEBOX("Found a mismatch on " + m.ccinv + ":" + m.Slsman)
        lcMess = "Found a mismatch on " + m.ccinv + m.Slsman + " cRate = " + ;
        	TRANSFORM(m.cRate)  + " laArr[1]= " + TRANSFORM(m.lcRate)
	_cliptext = _cliptext + m.lcMess
        =File_Log(m.lcMess ;
                  + " Cnt:" + TRANSFORM(laArr[1,2]) 
                  + " Fnd:" + TRANSFORM(m.llSeekfnd) 
                  + Chr(13)+chr(10))
        for lnRun = 1 to min(alen(laArrChk, 1), m.lnCheck)
           =File_Log(":1:" + Transform(laArrChk[m.lnRun, 1])  ;
                    +":2:" + Transform(laArrChk[m.lnRun, 2])  ;
                    +":3:" + Transform(laArrChk[m.lnRun, 3])  ;
                    +":4:" + Transform(laArrChk[m.lnRun, 4])  ;
                    +":5:" + Transform(laArrChk[m.lnRun, 5])  ;
                    +":6:" + Transform(laArrChk[m.lnRun, 6])  ;
                    +":7:" + Transform(laArrChk[m.lnRun, 7])  ;
                    +":8:" + Transform(laArrChk[m.lnRun, 8])  ;
                    +":9:" + Transform(laArrChk[m.lnRun, 9])  ;
                    +Chr(13)+chr(10))
        next
ENDIF
regards

thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform