Revision 5547
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/vegbien.my.sql | ||
---|---|---|
180 | 180 |
|
181 | 181 |
|
182 | 182 |
-- |
183 |
-- Name: taxonconcept_3_parent_id_avoid_self_ref(); Type: FUNCTION; Schema: public; Owner: - |
|
184 |
-- |
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
-- |
|
183 | 190 |
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: - |
184 | 191 |
-- |
185 | 192 |
|
... | ... | |
4111 | 4118 |
|
4112 | 4119 |
|
4113 | 4120 |
-- |
4121 |
-- Name: taxonconcept_3_parent_id_avoid_self_ref; Type: TRIGGER; Schema: public; Owner: - |
|
4122 |
-- |
|
4123 |
|
|
4124 |
|
|
4125 |
|
|
4126 |
|
|
4127 |
-- |
|
4114 | 4128 |
-- Name: taxonconcept_update_ancestors; Type: TRIGGER; Schema: public; Owner: - |
4115 | 4129 |
-- |
4116 | 4130 |
|
schemas/vegbien.sql | ||
---|---|---|
472 | 472 |
|
473 | 473 |
|
474 | 474 |
-- |
475 |
-- Name: taxonconcept_3_parent_id_avoid_self_ref(); Type: FUNCTION; Schema: public; Owner: - |
|
476 |
-- |
|
477 |
|
|
478 |
CREATE FUNCTION taxonconcept_3_parent_id_avoid_self_ref() RETURNS trigger |
|
479 |
LANGUAGE plpgsql |
|
480 |
AS $$ |
|
481 |
BEGIN |
|
482 |
new.parent_id = nullif(new.parent_id, new.taxonconcept_id); |
|
483 |
RETURN new; |
|
484 |
END; |
|
485 |
$$; |
|
486 |
|
|
487 |
|
|
488 |
-- |
|
475 | 489 |
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: - |
476 | 490 |
-- |
477 | 491 |
|
... | ... | |
4815 | 4829 |
|
4816 | 4830 |
|
4817 | 4831 |
-- |
4832 |
-- Name: taxonconcept_3_parent_id_avoid_self_ref; Type: TRIGGER; Schema: public; Owner: - |
|
4833 |
-- |
|
4834 |
|
|
4835 |
CREATE TRIGGER taxonconcept_3_parent_id_avoid_self_ref BEFORE INSERT OR UPDATE ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_3_parent_id_avoid_self_ref(); |
|
4836 |
|
|
4837 |
|
|
4838 |
-- |
|
4818 | 4839 |
-- Name: taxonconcept_update_ancestors; Type: TRIGGER; Schema: public; Owner: - |
4819 | 4840 |
-- |
4820 | 4841 |
|
Also available in: Unified diff
schemas/vegbien.sql: taxonconcept: Added taxonconcept_3_parent_id_avoid_self_ref() trigger to avoid recursive references in root taxonconcepts (taxonconcepts with no parent). This will simplify the new taxonconcept_update_ancestors() trigger.