Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在继承子项的Postgresql 9之间共享父触发器_Postgresql - Fatal编程技术网

在继承子项的Postgresql 9之间共享父触发器

在继承子项的Postgresql 9之间共享父触发器,postgresql,Postgresql,我想为“parent”创建一个触发器,当我在child1、child2或child3上插入时,该触发器必须自动执行。 但似乎不起作用,我必须为每个孩子创建一个触发器。 postgresql 9的任何解决方案?每个子表都需要一个触发器 但是,由于所有触发器都可以指向相同的功能,因此可以减轻维护负担: create table parent(...); create table child1(...) inherits parent; create table child2(...) inheri

我想为“parent”创建一个触发器,当我在child1、child2或child3上插入时,该触发器必须自动执行。 但似乎不起作用,我必须为每个孩子创建一个触发器。
postgresql 9的任何解决方案?

每个子表都需要一个触发器

但是,由于所有触发器都可以指向相同的功能,因此可以减轻维护负担:

create table parent(...);

create table child1(...)
inherits parent;
create table child2(...)
inherits parent;
create table child3(...)
inherits parent;
CREATE TRIGGER trig1 AFTER INSERT ON child1 FOR EACH ROW
    EXECUTE PROCEDURE trigproc();

CREATE TRIGGER trig2 AFTER INSERT ON child2 FOR EACH ROW
    EXECUTE PROCEDURE trigproc();
...