Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
CREATE TRIGGER graffiti_bi 
BEFORE INSERT 
ON public.vw_graffiti 
FOR EACH ROW 
EXECUTE PROCEDURE insert_graffiti_record_with_audit();

-- With the procedure insert_graffiti_record_with_audit doing the actual processing.

CREATE OR REPLACE FUNCTION insertvw_graffiti_record_with_audittf()
  RETURNS TRIGGER 
  LANGUAGE PLPGSQL
AS
$$
BEGIN
  INSERT INTO public.graffiti (description,reportedby,reportedon,createdby,createdon)
		 VALUES(new.description,
				new.reportedby,
				new.reportedon,
				current_user,
				now() );
  RETURN NEW;
END;
$$;

CREATE TRIGGER graffiti_bi 
INSTEAD OF INSERT
ON public.vw_graffiti 
FOR EACH ROW 
EXECUTE PROCEDURE vw_graffiti_tf();

This example shows the power of combining Weave processing and/or database processing.

...