I have the following code:
create or replace trigger calckmdl
after delete on tsegmento
for each row
declare
total rutas.km%type;
begin
if deleting then
select km into total from rutas where ruta=:new.ruta;
if :old.unidad = 'km' then
total:=total-:old.distancia;
end if;
else if :old.unidad = 'm' then
total:=total-:old.distancia/1000;
end if;
update rutas set km=total where ruta=:new.ruta;
end if
When I make a DELETE, I always miss the error "No data found" . I've been breaking my head for weeks, I do not understand what the problem is. I have a trigger for INSERT and UPDATE of the same style and they work perfectly.