Revision 5473
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/vegbien.my.sql | ||
---|---|---|
159 | 159 |
|
160 | 160 |
|
161 | 161 |
-- |
162 |
-- Name: taxonconcept_2_propagate_accepted_concept_id(); Type: FUNCTION; Schema: public; Owner: - |
|
163 |
-- |
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
-- |
|
162 | 169 |
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: - |
163 | 170 |
-- |
164 | 171 |
|
... | ... | |
4069 | 4076 |
|
4070 | 4077 |
|
4071 | 4078 |
-- |
4079 |
-- Name: taxonconcept_2_propagate_accepted_concept_id; Type: TRIGGER; Schema: public; Owner: - |
|
4080 |
-- |
|
4081 |
|
|
4082 |
|
|
4083 |
|
|
4084 |
|
|
4085 |
-- |
|
4072 | 4086 |
-- Name: taxonconcept_update_ancestors; Type: TRIGGER; Schema: public; Owner: - |
4073 | 4087 |
-- |
4074 | 4088 |
|
schemas/vegbien.sql | ||
---|---|---|
417 | 417 |
|
418 | 418 |
|
419 | 419 |
-- |
420 |
-- Name: taxonconcept_2_propagate_accepted_concept_id(); Type: FUNCTION; Schema: public; Owner: - |
|
421 |
-- |
|
422 |
|
|
423 |
CREATE FUNCTION taxonconcept_2_propagate_accepted_concept_id() RETURNS trigger |
|
424 |
LANGUAGE plpgsql |
|
425 |
AS $$ |
|
426 |
BEGIN |
|
427 |
IF new.matched_concept_id IS NOT NULL THEN |
|
428 |
IF new.matched_concept_id = new.taxonconcept_id THEN -- self-reference |
|
429 |
new.accepted_concept_id = new.taxonconcept_id;-- make self-reference |
|
430 |
ELSE -- propagate from matched concept |
|
431 |
new.accepted_concept_id = ( |
|
432 |
SELECT accepted_concept_id |
|
433 |
FROM taxonconcept |
|
434 |
WHERE taxonconcept_id = new.matched_concept_id |
|
435 |
); |
|
436 |
END IF; |
|
437 |
END IF; |
|
438 |
RETURN new; |
|
439 |
END; |
|
440 |
$$; |
|
441 |
|
|
442 |
|
|
443 |
-- |
|
420 | 444 |
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: - |
421 | 445 |
-- |
422 | 446 |
|
... | ... | |
4734 | 4758 |
|
4735 | 4759 |
|
4736 | 4760 |
-- |
4761 |
-- Name: taxonconcept_2_propagate_accepted_concept_id; Type: TRIGGER; Schema: public; Owner: - |
|
4762 |
-- |
|
4763 |
|
|
4764 |
CREATE TRIGGER taxonconcept_2_propagate_accepted_concept_id BEFORE INSERT OR UPDATE ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_2_propagate_accepted_concept_id(); |
|
4765 |
|
|
4766 |
|
|
4767 |
-- |
|
4737 | 4768 |
-- Name: taxonconcept_update_ancestors; Type: TRIGGER; Schema: public; Owner: - |
4738 | 4769 |
-- |
4739 | 4770 |
|
Also available in: Unified diff
schemas/vegbien.sql: taxonconcept: Added taxonconcept_2_propagate_accepted_concept_id() trigger to auto-populate the accepted_concept_id