>I have looked over the coding and test it, it seems to work, until recently, the actual live data is coming differently. What I am doing here in this DO CASE...ENDCASE is that this CASE is when there are two tables (a table and a cursor) have same number of records and then I need to compair side by side to see if either it is a "CHANGED" (would then be APPENDed to tab3) or "NO ACTION" (would then be APPENDed to tab2). I know we went thru this before, but this time I am overlooking something, so I need your help (furthermore, if you see something that can be improved or a better way of doing this, post it). Here we go...
>
>
>
> CASE _tally = ct && (means both tables has same counts, so need to verify side-by-side)
> exitloop=.F.
> SELECT histpo
> COPY TO histtemp FOR po = varpo && (to be able to DELETE recs in a table, not the live table)
> USE histtemp IN 0
> SELECT tempcur
> COPY TO temptemp && (to be able to DELETE recs in a tables, not in a cursor)
> USE temptemp IN 0
> SELECT temptemp
> GO TOP
> DO WHILE NOT EOF()
> SELECT temptemp
> varclass = temptemp.class
> varfund = temptemp.fund
> varudds = temptemp.udds
> varamount = temptemp.amount
> varfy = temptemp.fy
> varactivity = temptemp.activity
> varaccount = temptemp.account
> SELECT histtemp
> GO TOP
> DO WHILE NOT EOF()
> IF histtemp.class = varclass AND ;
> histtemp.fund = varfund AND ;
> histtemp.udds = varudds AND ;
> histtemp.amount = varamount AND ;
> histtemp.fy = varfy AND ;
> histtemp.activity = varactivity AND ;
> histtemp.account = varaccount
> DELETE
> GO TOP
> SELECT temptemp
> DELETE
> GO TOP
> EXIT
> ELSE
> SKIP
> IF EOF()
> exitloop=.T.
> EXIT
> ENDIF
> ENDIF
> ENDDO
> IF exitloop=.T.
> EXIT
> ENDIF
> ENDDO
> SELECT histtemp
> COUNT TO tp1 FOR NOT DELETED()
> USE
> SELECT temptemp
> COUNT TO tp2 FOR NOT DELETED()
> USE
> IF tp1 = 0 and tp2 = 0
> SELECT tab2
> APPEND FROM DBF("tempcur")
> ELSE
> SELECT tab3
> APPEND FROM DBF("tempcur")
> ENDIF
> DELETE FILE histtemp.dbf
> DELETE FILE temptemp.dbf
Hi Chuck,
I don't think I correctly get it reading your comments + code. However here is my way of your code translated :
DO case
CASE _tally = ct
=DiscardDupes("histpo","tempcur")
SELECT (IIF(reccount("crsDupRecs") = 0, "tab2", "tab3"))
APPEND FROM DBF("tempcur")
ENDCASE
FUNCTION DiscardDupes
LPARAMETERS tcTable1, tcTable2
LOCAL lcGroupBy, ix
USE (tcTable1) in 0 again alias myAlias
lcGroupBy = ""
FOR ix = 1 to fcount("myAlias")
lcGroupBy = lcGroupBy+iif(empty(lcGroupBy),"",",")+padl(ix,3,"0")
ENDFOR
USE in "myAlias"
SELECT * from (tcTable1) ;
union all ;
select * from (tcTable2) ;
into cursor myCursor
SELECT * from myCursor ;
having cnt(*)>1 ;
group by &lcGroupBy ;
into cursor crsDupRecs
SELECT * from myCursor ;
having cnt(*)=1 ;
group by &lcGroupBy ;
into cursor crsNoDupRecs
Cetin