我有以下触发器,我想在多个表中使用。那么,我怎样才能让它工作,而不是为每个表设置一个触发器呢?
BEGIN
IF (TG_OP = 'UPDATE') THEN
UPDATE test_table set rel_label = (select SUBSTR(release, 1, 5)) where uid=OLD.uid;
RETURN OLD;
ELSIF (TG_OP = 'INSERT') THEN
UPDATE test_table set rel_label = (select SUBSTR(release, 1, 5)) where uid=OLD.uid;
RETURN NEW;
END IF;
RETURN NULL; -- result ignored since is an AFTER TRIGGER
END;
问候。