Skip to content

Commit

Permalink
ajout trigger : création automatique des vues synthétiques des attrib…
Browse files Browse the repository at this point in the history
…uts par règnes
  • Loading branch information
amandine-sahl committed Sep 6, 2016
1 parent 3d4fb55 commit aca2061
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions data/taxhubdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ END;
$$;


CREATE OR REPLACE FUNCTION trg_fct_refresh_attributesviews_per_kingdom()
RETURNS trigger AS
$$
DECLARE
sregne text;
BEGIN
if NEW.regne IS NULL THEN
FOR sregne IN
SELECT DISTINCT regne
FROM taxonomie.taxref t
JOIN taxonomie.bib_noms n
ON t.cd_nom = n.cd_nom
LOOP
PERFORM taxonomie.fct_build_bibtaxon_attributs_view(sregne);
END LOOP;
ELSE
PERFORM taxonomie.fct_build_bibtaxon_attributs_view(NEW.regne);
END IF;
RETURN NEW;
END
$$ LANGUAGE plpgsql;
--
-- TOC entry 176 (class 1259 OID 101227)
-- Name: bib_attributs_id_attribut_seq; Type: SEQUENCE; Schema: taxonomie; Owner: -
Expand Down Expand Up @@ -764,6 +785,13 @@ CREATE INDEX i_taxref_hierarchy ON taxref USING btree (regne, phylum, classe, or
CREATE TRIGGER tri_insert_t_medias BEFORE INSERT ON t_medias FOR EACH ROW EXECUTE PROCEDURE insert_t_medias();



CREATE TRIGGER trg_refresh_attributes_views_per_kingdom
AFTER INSERT OR UPDATE OR DELETE
ON bib_attributs
FOR EACH ROW
EXECUTE PROCEDURE trg_fct_refresh_attributesviews_per_kingdom();

--
-- TOC entry 3394 (class 2606 OID 194367)
-- Name: bib_attributs_id_theme_fkey; Type: FK CONSTRAINT; Schema: taxonomie; Owner: -
Expand Down

0 comments on commit aca2061

Please sign in to comment.