TheLazyPig
Programmer
Hi!
Example that I have multiple dbf files and some of the tables have duplicates. I want to get all duplicates as well as the file name where the duplicate locates.
The problem is I'm not getting the correct file_src
It seems that it only gets the first file name but the correct is the other (green box).
**To get Duplicate
**To get DBF Files
The popfiles.prg procedure returns cursor with records matching wildcard skeleton inside the given base directory (subdirectories included)
Thank you in advance!!
Example that I have multiple dbf files and some of the tables have duplicates. I want to get all duplicates as well as the file name where the duplicate locates.
The problem is I'm not getting the correct file_src
It seems that it only gets the first file name but the correct is the other (green box).
**To get Duplicate
Code:
PROCEDURE withDuplicate()
local lnArea, lcTalk, llWithDup
lnArea = SELECT()
lcTalk = SET("Talk")
SET TALK ON
SELECT * ;
FROM curAll ;
WHERE REGCODE+DIVCODE+STACODE+EMPNO+POLICYNO+EFFYY+EFFMM+TERYY+TERMM IN ( ;
SELECT REGCODE+DIVCODE+STACODE+EMPNO+POLICYNO+EFFYY+EFFMM+TERYY+TERMM ;
FROM curAll ;
GROUP BY 1 ;
HAVING COUNT(*)>1 ;
) INTO CURSOR curDup READWRITE
llWithDup = reccount("curDup") > 0
IF llWithDup
[indent]
SELECT * FROM curDup INTO CURSOR curFil READWRITE
ALTER TABLE curFil ADD COLUMN file_src c(100)
REPLACE file_src WITH curData.filename FOR EMPTY(file_src) IN curFil
BROWSE
[/indent]
ENDIF
SELECT (lnArea)
RETURN llWithDup
ENDPROC
**To get DBF Files
Code:
LOCAL pcSearchType,pcCurName,pcMainPath,pcSrcPath,pcRptPath,lfilename,lnTotAmt
*----------------------------------
pcSearchDBF = "*.dbf"
pcSearchXLS = "*.xls"
pcCurName = "curData"
pcCurrDir = CURDIR()
pcScrPath = pcCurrDir+"\basket\"
sysDate = DTOS(DATE())
pcFileName = "consoldt_"+sysDate
pnCtr = 0
*----------------------------------
DO pcCurrDir+"popfiles" WITH pcScrPath, pcSearchXLS , pcCurName
IF ATC(".xls",curdata.filename) > 0
MESSAGEBOX(".xls file exists in basket!",48)
ELSE
DO pcCurrDir+"popfiles" WITH pcScrPath, pcSearchDBF, pcCurName
SELECT filename as name FROM &pcCurName INTO CURSOR curTemp
SELECT curTemp
SCAN
IF pnCtr = 0 THEN
USE (curTemp.name) NOUPDATE SHARED IN SELECT("crDbfRaw") AGAIN ALIAS crDbfRaw
SELECT * FROM crDbfRaw INTO CURSOR curAll READWRITE
ELSE
USE (curTemp.name) NOUPDATE SHARED IN SELECT("crDbfRaw") AGAIN ALIAS crDbfRaw
INSERT INTO curAll SELECT * FROM crDbfRaw
ENDIF
pnCtr = pnCtr + 1
ENDSCAN
The popfiles.prg procedure returns cursor with records matching wildcard skeleton inside the given base directory (subdirectories included)
Thank you in advance!!