SET FEEDBACK OFF

--ACTIVOS
DELETE FROM DISCOLURE.ACT_DETMOV;

DELETE FROM DISCOLURE.ACT_ETIQ;

DELETE FROM DISCOLURE.ACT_DETTR;

DELETE FROM DISCOLURE.ACT_MEJORA;

DELETE FROM DISCOLURE.ACT_ACTIVO;

DELETE FROM DISCOLURE.ACT_HISDETMOV;

DELETE FROM DISCOLURE.ACT_HISMOV;

delete FROM DISCOLURE.act_indice;

delete FROM DISCOLURE.act_movact;

update act_movconse
  set consecutivo=1;

-------------------------------------------
DELETE FROM DISCOLURE.ASIENTOCAJA;
-------------------------------------------

--BANCOS

DELETE FROM DISCOLURE.BANCOBROS;

DELETE FROM DISCOLURE.BANCON;

DELETE FROM DISCOLURE.BANESTDET;

DELETE FROM DISCOLURE.BANEST;

DELETE FROM DISCOLURE.BANFAC;

DELETE FROM DISCOLURE.BANHIS;

DELETE FROM DISCOLURE.BANMOVCHK;

DELETE FROM DISCOLURE.BANMOVTRS;

DELETE FROM DISCOLURE.BANMOV;

UPDATE BANMAE 
   SET CONSECUTIVO=1;

COMMIT;

--comisiones

DELETE FROM DISCOLURE.CMSACUAFIL;

delete FROM DISCOLURE.cmsacuklm;

delete FROM DISCOLURE.cmsadelanto;

delete FROM DISCOLURE.cmsaumento;

delete FROM DISCOLURE.CMSCLAVESEMP;

delete FROM DISCOLURE.cmsjefesdeptos;

delete FROM DISCOLURE.cmsklmmes;

delete FROM DISCOLURE.cmslabores;

delete FROM DISCOLURE.cmsmontos;

delete FROM DISCOLURE.cmspreafil;

delete FROM DISCOLURE.cmspremes;

delete FROM DISCOLURE.cmsrecom;

delete FROM DISCOLURE.cmsrecompre;

--COMPRAS

delete FROM DISCOLURE.comdetdistribucion;

delete FROM DISCOLURE.comdistribucion;

delete FROM DISCOLURE.comlogcxp;

delete FROM DISCOLURE.COM_CAMBIOS_ADUANa;

delete FROM DISCOLURE.COM_CARGOS_FACTURa;

delete FROM DISCOLURE.COM_CARGOS_nacionalizacion;

COMMIT;

update com_consecutivo
   set consec_orden=1, 
       consec_solicitud=1, 
       consec_reclamo=1,
       consec_recnac=1,
       consec_nacio=1;

delete FROM DISCOLURE.COM_DET_FAC_ORDEN;

delete FROM DISCOLURE.COM_DET_FACTURA;

delete FROM DISCOLURE.COM_DET_NACIONALIzacion;

delete FROM DISCOLURE.COM_DET_ORDEN;

delete FROM DISCOLURE.COM_MONTOPROV;

delete FROM DISCOLURE.COM_DET_RECIBO;

delete FROM DISCOLURE.COM_DET_RECLAMO;

delete FROM DISCOLURE.COM_DET_SOLICITUD;

delete FROM DISCOLURE.COM_ENC_FAC_ORDEN;

delete FROM DISCOLURE.COM_ENC_NACIONALIzacion;

delete FROM DISCOLURE.com_enc_factura;

delete FROM DISCOLURE.COM_ENC_ORDEN;

delete FROM DISCOLURE.COM_ENC_RECLAMO;

delete FROM DISCOLURE.COM_ENC_SOLICITUD;

delete FROM DISCOLURE.COM_EST_ORDEN;

delete FROM DISCOLURE.COM_HIST_DETFAC;

delete FROM DISCOLURE.COM_HIST_DETORD;

delete FROM DISCOLURE.COM_HIST_DETREC;

delete FROM DISCOLURE.COM_HIST_ENCFAC;

delete FROM DISCOLURE.COM_HIST_ENCORD;

delete FROM DISCOLURE.COM_HIST_ENCREC;

delete FROM DISCOLURE.COM_HIST_NACARA;

delete FROM DISCOLURE.COM_HIST_DETNAC;

delete FROM DISCOLURE.COM_HIST_ENCNAC;

COMMIT;

delete FROM DISCOLURE.COM_NAC_ARANCEL;

delete FROM DISCOLURE.COM_PRORECIBO;

delete FROM DISCOLURE.COM_ENC_RECIBO;

--Cxp

DELETE FROM DISCOLURE.CXP_ASIENTO;

DELETE FROM DISCOLURE.CXP_CHEQUES;

UPDATE CXP_CON_DOCUMENTO
   SET CONSECUTIVO=1;

DELETE FROM DISCOLURE.CXP_CREDITO;

DELETE FROM DISCOLURE.CXP_CREDITO_TMP;

DELETE FROM DISCOLURE.CXP_DET_DESCU;

DELETE FROM DISCOLURE.CXP_DET_GEN_PAGO;

DELETE FROM DISCOLURE.CXP_DET_MOVIMIENTO;

DELETE FROM DISCOLURE.CXP_DET_MOVIMIENTO_HIST;

DELETE FROM DISCOLURE.CXP_DET_PAGO_NOTA;

DELETE FROM DISCOLURE.CXP_DET_PAGO_NOTA_HIST;

DELETE FROM DISCOLURE.CXP_ENC_GEN_PAGO;

DELETE FROM DISCOLURE.CXP_ENC_MOVIMIENTO_CON;

DELETE FROM DISCOLURE.CXP_ENC_MOVIMIENTO_HIST;

DELETE FROM DISCOLURE.CXP_ENC_PAGO_NOTA_HIST;

DELETE FROM DISCOLURE.CXP_MOVIMIENTOTMP;

DELETE FROM DISCOLURE.CXP_OBLIGACION;

DELETE FROM DISCOLURE.CXP_PAGO_NOTA_CON;

DELETE FROM DISCOLURE.CXP_ENC_PAGO_NOTA;

DELETE FROM DISCOLURE.CXP_ENC_MOVIMIENTO;

COMMIT;

--Conta

update conconsecdist
set consecutivo=1, 
    temporal=1;

delete FROM DISCOLURE.condetdistribucion;

delete FROM DISCOLURE.CONDISTRIBUCION;

delete FROM DISCOLURE.conresdistribucion;

delete FROM DISCOLURE.CON_CONSEC_ASIE;

delete FROM DISCOLURE.CON_DET_ASIENTO;

delete FROM DISCOLURE.CON_ENC_ASIENTO;

delete FROM DISCOLURE.CON_HIS_DET_ASIENTO;

delete FROM DISCOLURE.CON_HIS_ENC_ASIENTO;

delete FROM DISCOLURE.CON_HIS_SALDO_CONTA;

delete FROM DISCOLURE.CON_PRE;

delete FROM DISCOLURE.CON_SALDO_VMONEDA;

delete FROM DISCOLURE.CON_TMP_SALDODIST;

--Cobros

delete FROM DISCOLURE.CXCDETDISTRIBUCION;

delete FROM DISCOLURE.CXCDISTRIBUCION;

delete FROM DISCOLURE.CXC_AGE_COBRO;

delete FROM DISCOLURE.CXC_ASIENTO;

delete FROM DISCOLURE.CXC_AUTORIZACION;

delete FROM DISCOLURE.CXC_CHEQUES;

delete FROM DISCOLURE.CXC_CLICOMISION;

delete FROM DISCOLURE.CXC_CLICOM_COBRO;

delete FROM DISCOLURE.CXC_CLIENTE_PERSONA;

update CXC_CON_DOCUMENTO
   set consecutivo=1;

COMMIT;

delete FROM DISCOLURE.CXC_CREDITO_TMP;

delete FROM DISCOLURE.CXC_DEPOSITOS;

delete FROM DISCOLURE.CXC_DETAGECXCTMP;

delete FROM DISCOLURE.CXC_DET_COMISION;

delete FROM DISCOLURE.CXC_DET_PAGO_NOTA;

delete FROM DISCOLURE.CXC_DET_PAGO_NOTATMP;

delete FROM DISCOLURE.CXC_DET_PAGO_NOTA_HIST;

delete FROM DISCOLURE.CXC_DIF_RECIBOS;

delete FROM DISCOLURE.CXC_DOCUMENTO_CLIENTE;

delete FROM DISCOLURE.CXC_ENCAGECXCTMP;

delete FROM DISCOLURE.CXC_ENC_MOVIMIENTO_CON;

delete FROM DISCOLURE.CXC_ENC_MOVIMIENTO_HIST;

delete FROM DISCOLURE.CXC_ENC_PAGO_NOTATMP;

delete FROM DISCOLURE.CXC_ENC_PAGO_NOTA_HIST;

delete FROM DISCOLURE.CXC_OBLIGACION;

delete FROM DISCOLURE.CXC_ENC_MOVIMIENTO;

delete FROM DISCOLURE.CXC_CREDITO;

delete FROM DISCOLURE.CXC_OBLIGACIONTMP;

delete FROM DISCOLURE.CXC_PAGO_CCSS;

delete FROM DISCOLURE.CXC_PAGO_NOTA_CON;

delete FROM DISCOLURE.CXC_RECAGENTE;

delete FROM DISCOLURE.CXC_ENC_PAGO_NOTA;

delete FROM DISCOLURE.CXC_RECAGTMP;

delete FROM DISCOLURE.CXC_RECIBOS_AGENTES;

delete FROM DISCOLURE.CXC_TRAMITES;

delete FROM DISCOLURE.CXC_TRAMITES_PROCESOS;

COMMIT;

--estadisticas

delete FROM DISCOLURE.estdet;

delete FROM DISCOLURE.EST_COMAGENTE;

delete FROM DISCOLURE.EST_LINEA_TMP;

delete FROM DISCOLURE.EST_PROVEEDOR_TMP;

--fac
DELETE FROM DISCOLURE.PREDESCCLASE;

DELETE FROM DISCOLURE.PREDETPROMOCION;

DELETE FROM DISCOLURE.PREPRECIOPRO;

DELETE FROM DISCOLURE.PREPROMOCION;

--FRECUENTE

DELETE FROM DISCOLURE.FREDESCCOMPRAS;

DELETE FROM DISCOLURE.FREFACTORES;

DELETE FROM DISCOLURE.FREMONTOMAXIMO;

DELETE FROM DISCOLURE.FREPORCENTAJE;

DELETE FROM DISCOLURE.FREPUNTOS;

--ventas

delete FROM DISCOLURE.VENARQUEODET;

delete FROM DISCOLURE.VENARQUEO;

delete FROM DISCOLURE.VENBLOQUES;

delete FROM DISCOLURE.VENCAMION;

delete FROM DISCOLURE.VENCARGO;

delete FROM DISCOLURE.VENDETCATALOGO;

delete FROM DISCOLURE.VENCATALOGO;

delete FROM DISCOLURE.VENCLASECLI;

delete FROM DISCOLURE.VENCLITMP;

update VENCONSECUTIVO
   set documento=1;

delete FROM DISCOLURE.VENCONSIGNATARIO
where consignatario!='001';

delete FROM DISCOLURE.VENDESCUENTOVOL;

delete FROM DISCOLURE.VENDESPACHO;

delete FROM DISCOLURE.VENDETALISTO;

delete FROM DISCOLURE.VENDETCIERRE;

delete FROM DISCOLURE.VENCIERRE;

delete FROM DISCOLURE.VENDETDEPOSITO;

delete FROM DISCOLURE.VENDETDEVOLUCION;

delete FROM DISCOLURE.VENDETFACTURA;

delete FROM DISCOLURE.VENDETGUIA;

delete FROM DISCOLURE.VENDETNOTA;

delete FROM DISCOLURE.VENDETPRESUPUESTO;

delete FROM DISCOLURE.VENDETRESERVA;

delete FROM DISCOLURE.VENDETPEDIDO;

delete FROM DISCOLURE.VENDEVOLUCION;

delete FROM DISCOLURE.VENENVIO;

delete FROM DISCOLURE.VENEVENTOALISTO;

delete FROM DISCOLURE.VENALISTO;

delete FROM DISCOLURE.VENEMPLEADO;

delete FROM DISCOLURE.VENDEPOSITO;

delete FROM DISCOLURE.VENFACTMP;

delete FROM DISCOLURE.VENFACTURA;

delete FROM DISCOLURE.VENFONDODET;

delete FROM DISCOLURE.VENGUIA;

delete FROM DISCOLURE.VENLIQVALE;

delete FROM DISCOLURE.VENLISTANEGRA;

delete FROM DISCOLURE.VENNOTA;

delete FROM DISCOLURE.VENPAGODOCUMENTOS;

delete FROM DISCOLURE.VENPAGOVALORES;

delete FROM DISCOLURE.VENPEDIDO;

delete FROM DISCOLURE.VENPREMIOS;

delete FROM DISCOLURE.VENPRESUPUESTO;

delete FROM DISCOLURE.VENSALSERVICIO;

delete FROM DISCOLURE.VENSERVICIO;

delete FROM DISCOLURE.VENPAGO;

delete FROM DISCOLURE.VENTRANSACCION;

delete FROM DISCOLURE.VENVALE;

delete FROM DISCOLURE.VENVERALISTO;

--INVENTAR

DELETE FROM DISCOLURE.INVTMP;

DELETE FROM DISCOLURE.INV_ACUM_PERIODO;

DELETE FROM DISCOLURE.INV_ARTABC_TMP;

DELETE FROM DISCOLURE.INV_ARTICULOBOD;

DELETE FROM DISCOLURE.INV_ARTICULO_CON_LOTE;

DELETE FROM DISCOLURE.INV_ARTIC_CODBAR;

DELETE FROM DISCOLURE.INV_ARTIC_LOCBOD;

DELETE FROM DISCOLURE.INV_ARTIC_MEDIDA;

DELETE FROM DISCOLURE.INV_ARTIC_PROV;

DELETE FROM DISCOLURE.INV_BODEGA
WHERE COD_BODEGA!='001';

UPDATE INV_CONSEC_MOVTOS
   SET NUM_MOVTO=1;

DELETE FROM DISCOLURE.INV_DETALLES;

DELETE FROM DISCOLURE.INV_DETMOVDESP;

DELETE FROM DISCOLURE.INV_DETMOVIMIENTO;

DELETE FROM DISCOLURE.INV_DETSOLTRASLADO;

DELETE FROM DISCOLURE.INV_DETTOMAFIS;

DELETE FROM DISCOLURE.INV_DIFTOMAFIS;

DELETE FROM DISCOLURE.INV_DINTOMAFIS;

DELETE FROM DISCOLURE.INV_ENCABTRASLADO;

DELETE FROM DISCOLURE.INV_ENCABMOVIMIENTO;

DELETE FROM DISCOLURE.INV_ENCMOVDESP;

DELETE FROM DISCOLURE.INV_ENCSOLTRASLADO;

DELETE FROM DISCOLURE.INV_GRUPODET;

DELETE FROM DISCOLURE.INV_HIST_DET_MOVTO;

DELETE FROM DISCOLURE.INV_HIST_ENC_MOVTO;

DELETE FROM DISCOLURE.INV_HIST_LOTE;

--PRECIOS

DELETE FROM DISCOLURE.PREC_AUTORIZA;
DELETE FROM DISCOLURE.PREC_PROVEEDOR;
DELETE FROM DISCOLURE.PREDESCUSUARIO;
DELETE FROM DISCOLURE.PREDETLISTA;
DELETE FROM DISCOLURE.PREDETLISTA_HIST;
DELETE FROM DISCOLURE.PREESPECIALES;
DELETE FROM DISCOLURE.PRELISTARES;

COMMIT;

DELETE FROM DISCOLURE.INV_GRUPO;

DELETE FROM DISCOLURE.INV_ARTICULOBOD;

DELETE FROM DISCOLURE.INV_LOTE_ARTIC_BODEGA;

DELETE FROM DISCOLURE.INV_LOC;

DELETE FROM DISCOLURE.INV_LOTE;

DELETE FROM DISCOLURE.INV_MENSUALTMP;

DELETE FROM DISCOLURE.INV_MOVGRUPODET;

DELETE FROM DISCOLURE.INV_MOVGRUPO;

DELETE FROM DISCOLURE.INV_PENMOVIMIENTO;

DELETE FROM DISCOLURE.INV_SUSTITUTO;

DELETE FROM DISCOLURE.INV_TABLABONIFIC;

DELETE FROM DISCOLURE.INV_TABLADESC;

DELETE FROM DISCOLURE.INV_TMP_CRITERIOS;

DELETE FROM DISCOLURE.INV_TOMAFIS;

DELETE FROM DISCOLURE.INV_GRUPO;

DELETE FROM DISCOLURE.INV_ARTICULO;

DELETE FROM DISCOLURE.INV_COMB_LCM;

DELETE FROM DISCOLURE.INV_MARCA;

DELETE FROM DISCOLURE.INV_CLASE;

DELETE FROM DISCOLURE.INV_LINEA;

COMMIT;



COMMIT;
--GENERAL

DELETE FROM DISCOLURE.GENHISTIMP;
DELETE FROM DISCOLURE.GENIMPBARRAS;
DELETE FROM DISCOLURE.GEN_AGENTEAUT;
DELETE FROM DISCOLURE.GEN_CAMB_PRECIO;
DELETE FROM DISCOLURE.GEN_CLIENTE_ACCION;
DELETE FROM DISCOLURE.GEN_CLIENTE_BITACORA;
DELETE FROM DISCOLURE.GEN_CLIENTE_CLASIF;
DELETE FROM DISCOLURE.GEN_CLIENTE_REFERENCIA;
DELETE FROM DISCOLURE.GEN_CLIE_AGENTE;
DELETE FROM DISCOLURE.GEN_COM_AGENTE;
DELETE FROM DISCOLURE.GEN_CONTCLIE;
DELETE FROM DISCOLURE.GEN_CONTPROV;
DELETE FROM DISCOLURE.GEN_IMP_BARRAS;
DELETE FROM DISCOLURE.GEN_INCON_CAMPRE;
DELETE FROM DISCOLURE.PREINCONSCAMBIO;
DELETE FROM DISCOLURE.PREENCCAMBIO;
DELETE FROM DISCOLURE.GEN_PROV_COMISION;
DELETE FROM DISCOLURE.GEN_SOBREG_CLIENTE;
DELETE FROM DISCOLURE.GEN_SOBREG_PROVEEDOR;
COMMIT;



DELETE FROM DISCOLURE.GEN_CLIENTE
WHERE COD_CLIENTE NOT IN('001', '002');
DELETE FROM DISCOLURE.GEN_PERSONA;
DELETE FROM DISCOLURE.GEN_PROVEEDOR;
DELETE FROM DISCOLURE.GEN_OFICINA
WHERE SUCURSAL !='001';
DELETE FROM DISCOLURE.GEN_SUCURSAL
WHERE SUCURSAL !='001';

DELETE FROM DISCOLURE.movimientocaja;
DELETE FROM DISCOLURE.movimientoVENTA;

DELETE FROM DISCOLURE.OPERACIONCAJA
where dia not between  to_date('1/11/2005', 'dd/mm/yyyy')
                     and to_date('30/11/2005', 'dd/mm/yyyy');

delete FROM DISCOLURE.caja
where cajero!='001';

DELETE FROM DISCOLURE.BALANCECAJA;

DELETE FROM DISCOLURE.CAJERO
WHERE CAJERO!='001';

update cajero set usuario=user;

select table_name FROM DISCOLURE.user_constraints
where constraint_name='GEN_COMPANIA_INVPARAM_FK';

DELETE FROM DISCOLURE.VENCONCEPTOVAL WHERE CIA='002';

DELETE FROM DISCOLURE.CONCEPTOVENTA WHERE CIA='002';
DELETE VENTIPODOC WHERE CIA='002';
DELETE VENPARAMETROS WHERE CIA='002';
DELETE FROM DISCOLURE.CONCEPTO WHERE CIA='002';

DELETE FROM DISCOLURE.CON_CUENTA
WHERE COD_CIA='002';

commit;

DELETE FROM DISCOLURE.GEN_PERIODO_RANGO
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.SEG_GRANT
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.GEN_PERIODO
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.GEN_PARAMETRO
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.CON_PARAMETRO
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.GEN_SUCURSAL
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.INV_PARAMETRO
WHERE COD_CIA='002';

DELETE FROM DISCOLURE.GEN_COMPANIA
WHERE COD_CIA='002';


insert into gen_distrito
select * from system.gen_distrito
where (cod_provincia,cod_canton,cod_distrito) in 
(select cod_provincia,cod_canton,cod_distrito from system.gen_distrito
minus
select cod_provincia,cod_canton,cod_distrito from gen_distrito);
