Project

General

Profile

« Previous | Next » 

Revision 12013

schemas/vegbien.sql: locationevent: added locationevent_pull_forward_from_parent() trigger which populates project_id from the parent locationevent

View differences:

trunk/schemas/vegbien.my.sql
451 451

  
452 452

  
453 453
--
454
-- Name: locationevent_pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
455
--
456

  
457

  
458

  
459

  
460
--
461
-- Name: FUNCTION locationevent_pull_forward_from_parent(); Type: COMMENT; Schema: public; Owner: -
462
--
463

  
464

  
465

  
466

  
467
--
454 468
-- Name: locationevent_pull_forward_from_parent_for_stratum(); Type: FUNCTION; Schema: public; Owner: -
455 469
--
456 470

  
......
7861 7875

  
7862 7876

  
7863 7877
--
7878
-- Name: locationevent_pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
7879
--
7880

  
7881

  
7882

  
7883

  
7884
--
7864 7885
-- Name: locationevent_pull_forward_from_parent_for_stratum; Type: TRIGGER; Schema: public; Owner: -
7865 7886
--
7866 7887

  
trunk/schemas/vegbien.sql
880 880

  
881 881

  
882 882
--
883
-- Name: locationevent_pull_forward_from_parent(); Type: FUNCTION; Schema: public; Owner: -
884
--
885

  
886
CREATE FUNCTION locationevent_pull_forward_from_parent() RETURNS trigger
887
    LANGUAGE plpgsql
888
    AS $$
889
DECLARE
890
	parent locationevent;
891
BEGIN
892
	SELECT * INTO parent FROM locationevent WHERE locationevent_id = new.parent_id;
893
	
894
	IF new.project_id IS NULL THEN new.project_id = parent.project_id; END IF;
895
	
896
	RETURN new;
897
END;
898
$$;
899

  
900

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

  
905
COMMENT ON FUNCTION locationevent_pull_forward_from_parent() IS 'see wiki.vegpath.org/Pull-forward';
906

  
907

  
908
--
883 909
-- Name: locationevent_pull_forward_from_parent_for_stratum(); Type: FUNCTION; Schema: public; Owner: -
884 910
--
885 911

  
......
9478 9504

  
9479 9505

  
9480 9506
--
9507
-- Name: locationevent_pull_forward_from_parent; Type: TRIGGER; Schema: public; Owner: -
9508
--
9509

  
9510
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();
9511

  
9512

  
9513
--
9481 9514
-- Name: locationevent_pull_forward_from_parent_for_stratum; Type: TRIGGER; Schema: public; Owner: -
9482 9515
--
9483 9516

  

Also available in: Unified diff