Professional Documents
Culture Documents
declare
cursor c_socios is
select cuota_socio,nombre,apellidos,num_socio
from usuarios
where exists (select* from actividades_usuarios where
codigo_usuario=num_socio and codigo_actividad like 'am%' )
for update of cuota_socio nowait;
type t_socios is table of c_socios%rowtype
index by binary_integer;
vt_socios t_socios;
v_index binary_integer:=0;
v_i binary_integer:=0;
k_1 constant binary_integer:=18;
k_2 constant binary_integer:=36;
vinc number;
vinca number;
type r_a is record(
a number);
type ta is table of r_a
index by binary_integer;
vta ta;
begin
open c_socios;
loop
fetch c_socios into vt_socios(v_index);
exit when c_socios%notfound;
v_index:=v_index+1;
end loop;
close c_socios;
dbms_output.put_line('------------------------------------');
for vt_soc in c_socios loop
if vt_soc.cuota_socio <= k_1 then
vinc:=1.15;
vinca:=0.15;
elsif vt_soc.cuota_socio <= k_2 then
vinc:=1.10;
vinca:=0.10;
elsif vt_soc.cuota_socio > k_2 then
vinc:=1.05;
vinca:=0.05;
end if;
update usuarios
set cuota_socio=cuota_socio*vinc
where current of c_socios;
vta(v_i).a:=vt_soc.cuota_socio*vinca;
vt_socios(v_i).cuota_socio:=vt_soc.cuota_socio*vinc;
v_i:=v_i+1;
end loop;
end;