Project

General

Profile

« Previous | Next » 

Revision 11147

bugfix: schemas/vegbien.sql: locationevent: added pull-forward trigger to populate location_id from the parent event. a pull-forward trigger must be used for this (not a COALESCE in analytical_stem_view) because the locationevent cannot even be found by analytical_stem_view if it does not have an associated location.

View differences:

schemas/vegbien.my.sql
429 429

  
430 430

  
431 431
--
432
-- Name: locationevent__pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
433
--
434

  
435

  
436

  
437

  
438
--
439
-- Name: FUNCTION locationevent__pull_forward_from_parent(); Type: COMMENT; Schema: public; Owner: -
440
--
441

  
442

  
443

  
444

  
445
--
432 446
-- Name: make_family_higher_plant_group(); Type: FUNCTION; Schema: public; Owner: -
433 447
--
434 448

  
......
6143 6157

  
6144 6158

  
6145 6159
--
6160
-- Name: locationevent__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
6161
--
6162

  
6163

  
6164

  
6165

  
6166
--
6146 6167
-- Name: party_source_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
6147 6168
--
6148 6169

  
schemas/vegbien.sql
848 848

  
849 849

  
850 850
--
851
-- Name: locationevent__pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
852
--
853

  
854
CREATE FUNCTION locationevent__pull_forward_from_parent() RETURNS trigger
855
    LANGUAGE plpgsql
856
    AS $$
857
DECLARE
858
	parent locationevent;
859
BEGIN
860
	SELECT * INTO parent FROM locationevent WHERE locationevent_id = new.parent_id;
861
	
862
	IF new.location_id IS NULL THEN new.location_id = parent.location_id; END IF;
863
	
864
	RETURN new;
865
END;
866
$$;
867

  
868

  
869
--
870
-- Name: FUNCTION locationevent__pull_forward_from_parent(); Type: COMMENT; Schema: public; Owner: -
871
--
872

  
873
COMMENT ON FUNCTION locationevent__pull_forward_from_parent() IS 'see wiki.vegpath.org/Pull-forward';
874

  
875

  
876
--
851 877
-- Name: make_family_higher_plant_group(); Type: FUNCTION; Schema: public; Owner: -
852 878
--
853 879

  
......
7431 7457

  
7432 7458

  
7433 7459
--
7460
-- Name: locationevent__pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
7461
--
7462

  
7463
CREATE TRIGGER locationevent__pull_forward_from_parent BEFORE INSERT OR UPDATE OF locationevent_id, parent_id ON locationevent FOR EACH ROW WHEN ((new.parent_id IS NOT NULL)) EXECUTE PROCEDURE locationevent__pull_forward_from_parent();
7464

  
7465

  
7466
--
7434 7467
-- Name: party_source_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
7435 7468
--
7436 7469

  

Also available in: Unified diff