select PKCol ; from QorM ; into cursor DeleteThese nofilter ; where 'Dupe' $ ErrFlag1 + ErrFlag2 and DeletFails delete from QorM ; where PKCol in ( select PKCol from DeleteThese )The actual code could be reduced to delete with the first select as its inner select, but you get a chance to see what's about to be deleted when you split it into two SQLs.
> * Where there are dupes within a Quarterly <File Type> table > * and the user has flagged one of the recs of a dupe set as a > * non-error record, delete the other members of the dupe set. > > QIndexKey = key(tagno('CompSSNOEP'),'QorM') > set filter to 'Dupe'$ErrFlag1+ErrFlag2.and.QorM->DeletFails > count all to N > if N>0 > set fields to F1=&QIndexKey > GoodDupes = new array(N,1) > copy all to array GoodDupes > set fields to > set filter to 'Dupe'$ErrFlag1+ErrFlag2.and..not.QorM->DeletFails > delete for GoodDupes.Scan( &QIndexKey ) > 0 > endif > set filter to >