Un trigger en postgresql consta de una función, que es llamada desde el trigger propiamente dicho. Podemos llamar a la misma función desde mas de un trigger.
create or replace function puntoC()
returns trigger as $$
begin
if (old.x::integer%2= 0) then
update multiplos_2 set funcion_1 = round((3 * old.x) - 4, 2),
funcion_2 = round((3 * (old.x ^3)) - 5/2, 2),
funcion_3 = round((old.x / 3) * (-1) + 12, 2)
where multiplos_2.x = old.x
;
end if;
if (old.x%3= 0) then
update multiplos_3 set funcion_1 = round((3 * old.x) - 4, 2),
funcion_2 = round((3 * (old.x ^3)) - 5/2, 2),
funcion_3 = round((old.x / 3) * (-1) + 12, 2)
where multiplos_3.x = old.x
;
end if;
if (old.x%7= 0) then
update multiplos_7 set funcion_1 = round((3 * old.x) - 4, 2),
funcion_2 = round((3 * (old.x ^3)) - 5/2, 2),
funcion_3 = round((old.x / 3) * (-1) + 12, 2)
where multiplos_7.x = old.x
;
end if;
return old;
end;
$$
language plpgsql;
create trigger tg_puntoC
before delete
on funciones
for each row execute procedure puntoC();