create table fams as select distinct fam, familia from yyy where fam is not null; delete fams where fam='01' and familia like 'P%'; create table clas as select distinct fam||cla cla, clase from yyy where fam is not null; create table mars as select distinct fam||cla||ti mar, tipo from yyy where fam is not null and cla is not null; insert into inv_linea (COD_CIA,COD_LINEA,DES_LINEA,PRECIO_REGULADO,PORC_FINANCIERO,PORC_MAYORISTA,PORC_DETALLISTA) select '001', fam, familia, 'N', 0, null, null from fams; insert into inv_clase (COD_CIA,COD_CLASE,DES_CLASE,PORC_UTILIDAD) select '001', cla, substr(clase,1,30), null from clas; select count(distinct cla) from clas; delete clas where cla='011' and clase like 'M%'; insert into inv_marca (COD_CIA,COD_MARCA,DES_MARCA,PORC_UTILIDAD) select '001', mar, substr(tipo,1,30), null from mars; select count(distinct mar) from mars; delete mars where mar='01104' and tipo like 'M%'; insert into inv_comb_lcm (COD_CIA, COD_LINEA, COD_CLASE, COD_MARCA,PORC_UTILIDAD) select '001', substr(cod_marca,1,2), substr(cod_marca,1,3), cod_marca, 0 from inv_marca; create table reps as select codigo, count(*) conteo from inventario group by codigo having count(*)>1; declare cursor repetidos is select codigo, conteo from reps; begin for r in repetidos loop delete from inventario where codigo=r.codigo and rownum