La Web del Programador: Comunidad de Programadores
 
    Pregunta:  36355 - VERIFICAR DUPLICIDAD REGISTROS EN TABLAS - VISUAL FOX
Autor:  DAISY ANYUL LIZARAZO MONCADA
DESEO CONOCER COMO VERIFICO LA DUPLICIDAD DE REGISTROS EN UNA TABLA. TENGO EL CASO DE RECUPERAR LOS REGISTROS DE UNA TABLA ACTUALIZADA, PERO DICHA TABLA PUEDE TENER MAS REGISTROS, QUE LA TABLA DESACTUALIZADA, ENTONCES DESEO QUE ME LOS AGREGUE PERO QUE NO VAYA A AGREGAR UN REGISTRO YA EXISTENTE, NO MANEJO EN ESTAS TABLAS NINGUN CAMPO COMUN.

AGRADEZCO ME COLABOREN.

  Respuesta:  Arturo Garcia Casas
Hola saludos desde veracruz, ver.
te envio un pequeño codigo que a lo mejor te sirva de algo....lo que hace es comparar dos tablas con la misma informacion...checalo y cualquier duda no dudes en escribirme.....ok, chao.

EJEMPLO:

local folio,alta,existe
store 0 to folio,alta,existe
select 2 && tabla ACTUALIZADA
go top
do while .not. eof()
if fpeson01<>0 && verifica si el peso es mayor que cero
folio=ffolio01 && extrae el numero de folio
scatter TO memvar && graba en memoria todo el registro
select 1 && tabla DESACTUALIZADA
seek folio && busca el folio
if .not. found()
append from ARRAY memvar && lo agrega sino lo encuentra
alta=alta+1
wait \"Procesando Informacion...espere un momento \"+str(alta) window nowait
else
if found()
existe=existe+1
endif
endif
select 2 && tabla ACTUALIZADA
endif && si peso neto es diferente de cero
skip
enddo
messagebox(\"Se dieron de alta \"+allt(str(alta))+\" Registros...Nuevos ok\"+chr(13)+;
\"ya existen \"+allt(str(existe))+\" Registros...\"+chr(13)+;
\"Lo que hace un total de \"+allt(str(alta+existe))+\" Registros...\",\"Mensaje del sistema\")

bye...saludos