What happens is that I am trying to do a search in two tables and through cursors with parameters do the calculation of a tax and insert the data in a new table called taxes. I have three tables, AUTOMOVIL
, AVALUOS
e IMPUESTOS
.
These would be the tables Automovil
and Avaluos
. The idea is through a program PL / SQL insert PLACA
, VIGENCIA
and% Impuesto
that is calculated by applying the percentage of the tax to the value of the table automovil
. I do not know if there is an error with my logic; but when I try to make the inserts it does not leave any data in the table Impuestos
.
This is the script that I used:
set serveroutput on
set verify off
declare
cursor a is
select marca, placa, valor
from automovil;
cursor av (marc varchar2) is
select *
from avaluos
where marca = marc;
cursor imp is
select * from impuestos;
impu number;
pla varchar2(150);
vige number;
begin
for ra in a loop
pla := ra.placa;
for rav in av(ra.marca) loop
impu := ra.valor - (ra.valor * (rav.porcentaje/100));
vige := rav.vigencia;
for rimp in imp loop
insert into impuestos (placa, vigencia, impuesto)
values (pla, vige, impu);
commit;
end loop;
end loop;
end loop;
end;
/
They help me to see Where is the problem with the?