› Foros › Off-Topic › Miscelánea
declare
cursor cur1 is select pais, cdtercero, dstercero, cddnicif, cdcodabr, cdcuent from tabla1;
v_nif varchar2(25);
v_proveedor varchar2(10);
v_acreedor varchar2(10);
BEGIN
for c1 in cur1 loop
BEGIN
SELECT nif_code into v_nif from tabla2 where nif_code = c1.cddnicif;
EXCEPTION
when no_data_found then
dbms_output.put_line('No hay datos para ' || c1.cddnicif);
v_nif := NULL;
END;
IF v_nif = null then
INSERT INTO tabla2 values (c1.cddnicif, null, c1.dstercero, null, c1.cdtercero, null,sysdate, sysdate, null, c1.pais, null);
ELSE
select proveedor_number, acreedor_number into v_proveedor, v_acreedor from tabla2 where nif_code = c1.cddnicif;
IF v_proveedor = c1.cdtercero and v_acreedor is null then
UPDATE tabla2 set acreedor_number = c1.cdtercero where nif_code = c1.cddnicif;
ELSE
UPDATE tabla2 set proveedor_number = c1.cdtercero where nif_code = c1.cddnicif;
END IF;
END IF;
v_nif := null;
v_proveedor := null;
v_acreedor := null;
end loop;
EXCEPTION
when others then
dbms_output.put_line('error en ' || sqlerrm);
COMMIT;
END;
error en ORA-01403: No se ha encontrado ningún dato
Alberich escribió:select proveedor_number, acreedor_number into v_proveedor, v_acreedor from tabla2 where nif_code = c1.cddnicif;
Creo que esta select no la tienes controlada.