Based on the suggestions of jimstarr in a related topic I wrote a procedure to genericaly delete duplicate Records in any table. Say, I don't want to have to know what the table contains and I don't want to analyse the indexes and so on. I just want to delete duplicate records...
My code is:
This works fine with small tables but with mulitple fields the SELECT-Statement leads to a critical failure and vfp crashs. Think the number of allowed fields in the group by clause is restricted... Does anybody know a solution for a generic version?
thanks in advance for any suggestions
Andreas
My code is:
Code:
&& Deletes all duplicate Records out of the open table
&& Returns true on success else false
LOCAL AllFields,nCnt,nMax,cTableName
IF .NOT. (ALIAS() == "")
USE DBF() EXCL
AllFields = ""
nMax = FLDCOUNT()
nCnt = 1
DO WHILE nCnt <= nMax
AllFields = AllFields + FIELDS(nCnt) + ","
nCnt = nCnt + 1
ENDDO
IF .NOT. (AllFields == "")
AllFields = SUBSTR(AllFields,1,LEN(AllFields)-1)
ENDIF
cTableName = ALIAS()
SELECT * FROM (cTableName) INTO CURSOR mycursor GROUP BY &AllFields
SELECT (cTableName)
ZAP
APPEND FROM DBF('mycursor')
USE DBF()
RETURN .T.
ELSE
RETURN .F.
ENDIF
This works fine with small tables but with mulitple fields the SELECT-Statement leads to a critical failure and vfp crashs. Think the number of allowed fields in the group by clause is restricted... Does anybody know a solution for a generic version?
thanks in advance for any suggestions
Andreas