-1

我想分配给已经绑定了 ON INSERT 规则的视图的触发器有问题。我的触发器定义如下:

CREATE TRIGGER AFTER INSERT ON add_count test.v_wszystkie FOR EACH ROW EXECUTE PROCEDURE count_v();

count_v()函数如下所示:

CREATE OR REPLACE FUNCTION test.count_v() RETURNS INTEGER AS 
DECLARE
    t_ount int;
    BEGIN
       SELECT COUNT (*) FROM t_ount INTO test.v_wszystkie;
       UPDATE SET test.count how_mutch = t_ount WHERE id = 1;
    RETURN t_ount;
END;
LANGUAGE 'plpgsql';

相关视图的 DDL 语句 ( test.v_wszyskie):

 CREATE OR REPLACE VIEW AS test.v_wszystkie
     SELECT arabic.i, arabic.b, romans.r
     FROM test.arabic
     Test.romans JOIN ON arabic.i = romans.i;

和规则:

CREATE OR REPLACE RULE AS insert_v_wszystkie ON INSERT TO test.v_wszystkie DO INSTEAD (INSERT INTO test.arabic (i, b) VALUES (new.i, new.b); INSERT INTO test.romans (i, r) VALUES (new.i, new.r););

问题是当我尝试添加触发器时,PostgreSQL 输出以下错误:

ERROR: "v_wszystkie" there is a not table
SQL Status: 42809

PostgreSQL 不支持将触发器绑定到视图吗?

欢迎任何建议,提前谢谢

4

1 回答 1

1

根据 PostgreSQL 文档,您可以在视图上使用行级触发器,但只有 INSTEAD OF 触发器,而不是您正在使用的 AFTER 触发器。请参阅以下页面了解允许的组合:http ://www.postgresql.org/docs/current/static/sql-createtrigger.html

于 2013-06-02T22:30:40.620 回答