Project

General

Profile

« Previous | Next » 

Revision 5032

schemas/vegbien.sql: taxonpath.canon_taxonpath_id, placepath.canon_placepath_id: Added trigger to automatically create a self-reference (indicating a scrubbed name) when set to the special value 0

View differences:

schemas/vegbien.my.sql
117 117

  
118 118

  
119 119
--
120
-- Name: placepath_canon_placepath_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
121
--
122

  
123

  
124

  
125

  
126
--
120 127
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: -
121 128
--
122 129

  
......
131 138

  
132 139

  
133 140
--
141
-- Name: taxonpath_canon_taxonpath_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
142
--
143

  
144

  
145

  
146

  
147
--
134 148
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: -
135 149
--
136 150

  
......
4161 4175

  
4162 4176

  
4163 4177
--
4178
-- Name: placepath_canon_placepath_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4179
--
4180

  
4181

  
4182

  
4183

  
4184
--
4164 4185
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
4165 4186
--
4166 4187

  
......
4175 4196

  
4176 4197

  
4177 4198
--
4199
-- Name: taxonpath_canon_taxonpath_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4200
--
4201

  
4202

  
4203

  
4204

  
4205
--
4178 4206
-- Name: address_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4179 4207
--
4180 4208

  
schemas/vegbien.sql
309 309

  
310 310

  
311 311
--
312
-- Name: placepath_canon_placepath_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
313
--
314

  
315
CREATE FUNCTION placepath_canon_placepath_id_self_ref() RETURNS trigger
316
    LANGUAGE plpgsql
317
    AS $$
318
BEGIN
319
    IF new.canon_placepath_id = 0 THEN -- make self-reference
320
        new.placepath_id = nextval('placepath_placepath_id_seq'::regclass);
321
        new.canon_placepath_id = new.placepath_id;
322
    END IF;
323
    RETURN new;
324
END;
325
$$;
326

  
327

  
328
--
312 329
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: -
313 330
--
314 331

  
......
377 394

  
378 395

  
379 396
--
397
-- Name: taxonpath_canon_taxonpath_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
398
--
399

  
400
CREATE FUNCTION taxonpath_canon_taxonpath_id_self_ref() RETURNS trigger
401
    LANGUAGE plpgsql
402
    AS $$
403
BEGIN
404
    IF new.canon_taxonpath_id = 0 THEN -- make self-reference
405
        new.taxonpath_id = nextval('taxonpath_taxonpath_id_seq'::regclass);
406
        new.canon_taxonpath_id = new.taxonpath_id;
407
    END IF;
408
    RETURN new;
409
END;
410
$$;
411

  
412

  
413
--
380 414
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: -
381 415
--
382 416

  
......
945 979
-- Name: COLUMN placepath.canon_placepath_id; Type: COMMENT; Schema: public; Owner: -
946 980
--
947 981

  
948
COMMENT ON COLUMN placepath.canon_placepath_id IS 'The placepath containing the scrubbed name of this verbatim place path. placepaths should be linked only one level deep, with verbatim place paths pointing to scrubbed names.';
982
COMMENT ON COLUMN placepath.canon_placepath_id IS 'The placepath containing the scrubbed name of this verbatim place path. placepaths should be linked only one level deep, with verbatim place paths pointing to scrubbed names.
949 983

  
984
A scrubbed name should point to itself in this field. This is automatically created by setting this field to the special value 0.';
950 985

  
986

  
951 987
--
952 988
-- Name: COLUMN placepath.otherranks; Type: COMMENT; Schema: public; Owner: -
953 989
--
......
1158 1194
-- Name: COLUMN taxonpath.canon_taxonpath_id; Type: COMMENT; Schema: public; Owner: -
1159 1195
--
1160 1196

  
1161
COMMENT ON COLUMN taxonpath.canon_taxonpath_id IS 'The taxonpath containing the scrubbed name of this verbatim taxonomic name. taxonpaths should be linked only one level deep, with verbatim taxonomic names pointing to scrubbed names.';
1197
COMMENT ON COLUMN taxonpath.canon_taxonpath_id IS 'The taxonpath containing the scrubbed name of this verbatim taxonomic name. taxonpaths should be linked only one level deep, with verbatim taxonomic names pointing to scrubbed names.
1162 1198

  
1199
A scrubbed name should point to itself in this field. This is automatically created by setting this field to the special value 0.';
1163 1200

  
1201

  
1164 1202
--
1165 1203
-- Name: COLUMN taxonpath.taxon_id; Type: COMMENT; Schema: public; Owner: -
1166 1204
--
......
4767 4805

  
4768 4806

  
4769 4807
--
4808
-- Name: placepath_canon_placepath_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4809
--
4810

  
4811
CREATE TRIGGER placepath_canon_placepath_id_self_ref BEFORE INSERT OR UPDATE ON placepath FOR EACH ROW EXECUTE PROCEDURE placepath_canon_placepath_id_self_ref();
4812

  
4813

  
4814
--
4770 4815
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
4771 4816
--
4772 4817

  
......
4781 4826

  
4782 4827

  
4783 4828
--
4829
-- Name: taxonpath_canon_taxonpath_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4830
--
4831

  
4832
CREATE TRIGGER taxonpath_canon_taxonpath_id_self_ref BEFORE INSERT OR UPDATE ON taxonpath FOR EACH ROW EXECUTE PROCEDURE taxonpath_canon_taxonpath_id_self_ref();
4833

  
4834

  
4835
--
4784 4836
-- Name: address_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4785 4837
--
4786 4838

  

Also available in: Unified diff