CREATE FUNCTION f_bd_incidencias() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    BEGIN
	delete from imgincid where img_idinc=OLD.in_id;
	delete from operincid where oi_idinc=OLD.in_id;
    RETURN OLD;
END;$$;


ALTER FUNCTION public.f_bd_incidencias() OWNER TO sanjor;

CREATE TRIGGER bd_incidencias
    BEFORE DELETE ON incidencias
    FOR EACH ROW
    EXECUTE PROCEDURE f_bd_incidencias();

