Skip to content

Instantly share code, notes, and snippets.

@ignaciogutierrez
Created January 17, 2023 16:47
Show Gist options
  • Save ignaciogutierrez/c2ef116d9e76ac2975052f2086fee90b to your computer and use it in GitHub Desktop.
Save ignaciogutierrez/c2ef116d9e76ac2975052f2086fee90b to your computer and use it in GitHub Desktop.
Idea de clase para detectar y corregir tablas del modulo de inventario
return
*
* Permite detectar y corregir inconsistencias en las tablas del modulo de inventario
*
define class inconsistencias-inv as custom
function getDupArts()
select numart,count(1) as dup from arts group by numart order by dup desc having dup>1
into temp
function fixAllDupArts()
close database
* Obtener articulos duplicados en temp
this.getDupArts()
use arts order numart
select temp
scan
fixDupArts(temp.NUMART)
select temp
endscan
*
* Elimina los registros duplicados de UN articulo
* solo deja el primero que encuentra
function fixDupArts(cNumart)
select arts
seek cNumart
if not Found()
return
endif
* saltarme el primero, mantenerlo vivo
skip
scan while NUMART==cNumart
delete
endscan
EndDefine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment