All pastes #10171 Raw Edit

trigger

public sql v1 · immutable
#10171 ·published 2005-04-24 02:33 UTC
rendered paste body
CREATE TABLE categories (    catName text NOT NULL,    sortOrder integer,    parent text DEFAULT 'TOPLEVEL' NOT NULL,    category_template text,    category_template_timestamp timestamp,    primary key (catName),    foreign key (catName) references categorie_names(catName),    foreign key (parent) references categorie_names(catName));CREATE OR REPLACE FUNCTION categories_template_timstamp() RETURNS trigger AS '    BEGIN        NEW.category_template_timestamp := \'now\';        RETURN NEW;    END;' LANGUAGE plpgsql;CREATE TRIGGER categories_template_timstamp AFTER INSERT OR UPDATE ON categories    FOR EACH ROW EXECUTE PROCEDURE categories_template_timstamp();