recorrer una tabla
Buenas,
escribo para ver si me dais una idea, quiero recorrer una tabla y si hay un valor diferente hacer update, ademas hace de contador de valores iguales y diferentes.
declare
r number;
igual Number := 0;
diferente Number := 0;
no_existe number := 0;
esta boolean;
par_cat part_catalog_tab%ROWTYPE;
BEGIN
for r in 2..10 loop
/*esta:=true;
SELECT description
FROM part_catalog_tab
WHERE description = inventory_part_tab.description;
exception/*arreglar esto con un IF*/
/* WHEN no_data_found THEN
esta:=false;
no_existe := no_existe +1;
end;
if esta then*/
if r.description =part_cat.description then
igual:=igual+1;
else
UPDATE part_catalog_tab
SET (description)=
(select description
from inventory_part_tab
where contract='AI');
diferente:=diferente+1;
end if;
/*end if;*/
end Loop;
dbms_output.put('Il y a '||igual||' registres iguales');
dbms_output.put('Il y a '||diferente||' registres different');
dbms_output.put('Il n existe pas '||no_existe||' en CATALOG');
END;
escribo para ver si me dais una idea, quiero recorrer una tabla y si hay un valor diferente hacer update, ademas hace de contador de valores iguales y diferentes.
declare
r number;
igual Number := 0;
diferente Number := 0;
no_existe number := 0;
esta boolean;
par_cat part_catalog_tab%ROWTYPE;
BEGIN
for r in 2..10 loop
/*esta:=true;
SELECT description
FROM part_catalog_tab
WHERE description = inventory_part_tab.description;
exception/*arreglar esto con un IF*/
/* WHEN no_data_found THEN
esta:=false;
no_existe := no_existe +1;
end;
if esta then*/
if r.description =part_cat.description then
igual:=igual+1;
else
UPDATE part_catalog_tab
SET (description)=
(select description
from inventory_part_tab
where contract='AI');
diferente:=diferente+1;
end if;
/*end if;*/
end Loop;
dbms_output.put('Il y a '||igual||' registres iguales');
dbms_output.put('Il y a '||diferente||' registres different');
dbms_output.put('Il n existe pas '||no_existe||' en CATALOG');
END;
