创建约束触发器的Postgres语法错误

时间:2016-01-07 13:28:19

标签: postgresql triggers constraints plpgsql

我需要一个触发器来引起reindex(索引在一个不可变的函数上) 我将函数定义为

CREATE FUNCTION "TEST".triggerFuncTest()
RETURNS TRIGGER
AS $$
BEGIN
  REINDEX INDEX "TEST"."MyIndex";
  RETURN NULL;
END $$ LANGUAGE plpgsql;

带触发器

CREATE CONSTRAINT TRIGGER triggerTest
AFTER INSERT OR UPDATE OF indexes OR DELETE ON "TEST"."MyTable"
DEFERRABLE INITIALLY DEFERRED
FOR EACH STATEMENT
EXECUTE PROCEDURE "TEST".triggerFuncTest();

哪个给出了

ERROR:  syntax error at or near "STATEMENT"

但是如果我删除了CONSTRAINT和DEFERRABLE INITIALLY DEFERRED,则会创建触发器,但是这会在触发时引发异常。

0 个答案:

没有答案