Project

General

Profile

« Previous | Next » 

Revision 6794

schemas/vegbien.sql: sourcename: Added sourcename_set_matched_source_id() trigger

View differences:

schemas/vegbien.my.sql
395 395

  
396 396

  
397 397
--
398
-- Name: sourcename_set_matched_source_id(); Type: FUNCTION; Schema: public; Owner: -
399
--
400

  
401

  
402

  
403

  
404
--
398 405
-- Name: sync_analytical_aggregate_to_view(); Type: FUNCTION; Schema: public; Owner: -
399 406
--
400 407

  
......
5432 5439

  
5433 5440

  
5434 5441
--
5442
-- Name: sourcename_set_matched_source_id; Type: TRIGGER; Schema: public; Owner: -
5443
--
5444

  
5445

  
5446

  
5447

  
5448
--
5435 5449
-- Name: taxondetermination_set_iscurrent; Type: TRIGGER; Schema: public; Owner: -
5436 5450
--
5437 5451

  
schemas/vegbien.sql
899 899

  
900 900

  
901 901
--
902
-- Name: sourcename_set_matched_source_id(); Type: FUNCTION; Schema: public; Owner: -
903
--
904

  
905
CREATE FUNCTION sourcename_set_matched_source_id() RETURNS trigger
906
    LANGUAGE plpgsql
907
    AS $$
908
BEGIN
909
    IF new.matched_source_id IS NULL THEN -- populate matched_source_id
910
        new.matched_source_id :=
911
            (SELECT source_id FROM source WHERE shortname = new.name);
912
    END IF;
913
    RETURN new;
914
END;
915
$$;
916

  
917

  
918
--
902 919
-- Name: sync_analytical_aggregate_to_view(); Type: FUNCTION; Schema: public; Owner: -
903 920
--
904 921

  
......
6507 6524

  
6508 6525

  
6509 6526
--
6527
-- Name: sourcename_set_matched_source_id; Type: TRIGGER; Schema: public; Owner: -
6528
--
6529

  
6530
CREATE TRIGGER sourcename_set_matched_source_id BEFORE INSERT OR UPDATE ON sourcename FOR EACH ROW EXECUTE PROCEDURE sourcename_set_matched_source_id();
6531

  
6532

  
6533
--
6510 6534
-- Name: taxondetermination_set_iscurrent; Type: TRIGGER; Schema: public; Owner: -
6511 6535
--
6512 6536

  

Also available in: Unified diff