Revision 12014
Added by Aaron Marcuse-Kubitza about 11 years ago
vegbien.sql | ||
---|---|---|
822 | 822 |
|
823 | 823 |
|
824 | 824 |
-- |
825 |
-- Name: location_set_top_plot(); Type: FUNCTION; Schema: public; Owner: - |
|
826 |
-- |
|
827 |
|
|
828 |
CREATE FUNCTION location_set_top_plot() RETURNS trigger |
|
829 |
LANGUAGE plpgsql |
|
830 |
AS $$ |
|
831 |
BEGIN |
|
832 |
new.top_plot = COALESCE( |
|
833 |
(SELECT top_plot FROM location WHERE location_id = new.parent_id), |
|
834 |
new.location_id); |
|
835 |
RETURN new; |
|
836 |
END; |
|
837 |
$$; |
|
838 |
|
|
839 |
|
|
840 |
-- |
|
841 |
-- Name: FUNCTION location_set_top_plot(); Type: COMMENT; Schema: public; Owner: - |
|
842 |
-- |
|
843 |
|
|
844 |
COMMENT ON FUNCTION location_set_top_plot() IS 'see wiki.vegpath.org/Pull-forward'; |
|
845 |
|
|
846 |
|
|
847 |
-- |
|
825 | 848 |
-- Name: locationevent__communities(integer); Type: FUNCTION; Schema: public; Owner: - |
826 | 849 |
-- |
827 | 850 |
|
... | ... | |
2144 | 2167 |
location_id integer NOT NULL, |
2145 | 2168 |
source_id integer NOT NULL, |
2146 | 2169 |
sourceaccessioncode text, |
2170 |
top_plot integer NOT NULL, |
|
2147 | 2171 |
parent_id integer, |
2148 | 2172 |
authorlocationcode text, |
2149 | 2173 |
place_id integer, |
... | ... | |
2197 | 2221 |
|
2198 | 2222 |
|
2199 | 2223 |
-- |
2224 |
-- Name: COLUMN location.top_plot; Type: COMMENT; Schema: public; Owner: - |
|
2225 |
-- |
|
2226 |
|
|
2227 |
COMMENT ON COLUMN location.top_plot IS 'autopopulated'; |
|
2228 |
|
|
2229 |
|
|
2230 |
-- |
|
2200 | 2231 |
-- Name: locationevent; Type: TABLE; Schema: public; Owner: -; Tablespace: |
2201 | 2232 |
-- |
2202 | 2233 |
|
... | ... | |
9504 | 9535 |
|
9505 | 9536 |
|
9506 | 9537 |
-- |
9538 |
-- Name: location_set_top_plot; Type: TRIGGER; Schema: public; Owner: - |
|
9539 |
-- |
|
9540 |
|
|
9541 |
CREATE TRIGGER location_set_top_plot BEFORE INSERT OR UPDATE OF location_id, top_plot, parent_id ON location FOR EACH ROW EXECUTE PROCEDURE location_set_top_plot(); |
|
9542 |
|
|
9543 |
|
|
9544 |
-- |
|
9507 | 9545 |
-- Name: locationevent_pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: - |
9508 | 9546 |
-- |
9509 | 9547 |
|
Also available in: Unified diff
schemas/vegbien.sql: location: added autopopulated top_plot