// Ejemplo
#Define lCONDICION_BORRADO (TotalCobrado > TotalFactura)
/*
El indice (permanente) que se ha de crear es
INDEX ON If(lCONDICION_BORRADO, "S", "N") TO Nombre_indice
donde lCONDICION_BORRADO se explica por sí misma
*/
SELECT (cAlias)
// nOrderIndiceCondicionBorrado: Orden para recorrer SOLO los que cumplen la condicion de borrado
SET ORDER TO nOrderIndiceCondicionBorrado
SEEK "S"
DO WHILE !Eof() .AND. lCONDICION_BORRADO
Rec_Lock(0)
DELETE
SKIP
ENDDO
UNLOCK
...
oDbf_2:= fAbreDbf( DB_ANPRC, FALSE ) // Abro la DB en modo exclusivo
// Campo CodItm
MsgMeter( {|oMeter,oTxt| fBorrando( oMeter, oTxt, oDbf_2, cCodigo, nEs, DB_ANPRC, 1 ) }, ;
"", "Borrando...")
oDbf_2:End() // la cierro, porque es de la época q se cerraba luego de su uso
...
// ---------------------------------------------------------------------------------------------
static procedure fBorrando( oMeter, oTxt, oDbf, cCodigo, nEsPadre, nEs, nCampo ) // No todos los parámetros son útiles en este sample
local bMeter, ;
...
// Odómetro
bMeter:= {|| oMeter:Set( nRecNos ), ;
SysRefresh(), ;
nRecNos += if( oMeter:nTotal >= 2500, 10, 1) }
oMeter:nTotal:= oDbf:LastRec()
nRecNos:= if( oMeter:nTotal >= 2500, 10, 1) // segun el total de registros muestra el avance del meter
oTxt:SetText( cMsgMet )
(oDbf:nArea)->( dbEval( {|| if( cCodigo == Left( oDbf:FieldGet( nCampo ), 3), (oDbf:Delete(), nBorrados++ ), ), ;
nEval++, ;
if( nRecNos!=nEval, , Eval( bMeter ) ) } ) )
end
oTxt:SetText( "Se Borraron "+Str(nBorrados,5)+" Registros" )
oMeter:Set( oMeter:nTotal )
oMeter:Refresh()
SysRefresh()
Inkey( 2 ) // Una parada traida de Clipper :)
if cKey != nil
Select ( oDbf:nArea )
FLock() // Acá seguramente tienes algo para bloquear todo el fichero en lugar de la FLock
while dBSeek( cKey ) // con lSoft si corresponde
if ::bOnPreDeleteDetail != nil
Eval( ::bOnPreDeleteDetail, Self )
end if
dBDelete()
if ::bOnPostDeleteDetail != nil
Eval( ::bOnPostDeleteDetail, Self )
end if
end while
dBCommit()
dBUnLock()
end if
cAlias2:=OpenDbf(mPath_Fich+"FHCARCK1.DBF",5,.T.,.F.,.F.,{mPath_Fich+"FHCARCK1.NTX"},"DBFNTX")
If cAlias2=""
return nil
endif
Select (cAlias2)
OrdsetFocus(1)
dbgotop()
ordscope(0,) // quitar scope, filtro o rango
ordscope(1,)
dbgotop()
nReg0 := 1000
nReg1 := 300000
ordscope(0,nReg0) // poner scope, filtro o rango
ordscope(1,nReg1)
dbgotop()
msgalert ( time() )
Do While !Eof()
Do While !Rlock()
msgalert ("Registro en uso")
Return
Enddo
(cAlias2)->(dbdelete())
skip
Enddo
msgalert ( time() )
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 54 guests