4

Please help get my head around trigger creation syntax

create trigger cool_trigger
    after insert or update
    on custom_object_reference
    deferrable initially deferred
    for each statement
    execute procedure do_something();

syntax error at or near "deferrable"

I am using PostgreSQL 9.6.7

2
  • Never used that defer thing but from the documentation, it sounds like you should either put DEFERRABLE or INITIALLY DEFERRED, not both - have you tried putting only one? Commented Apr 10, 2018 at 16:17
  • Tried different ways, neither worked. Commented Apr 10, 2018 at 16:19

1 Answer 1

11

Only a constraint trigger can be deferred, so you'll have to use

CREATE CONSTRAINT TRIGGER ...

As the documentation says, you can only do this for AFTER ROW triggers.

Sign up to request clarification or add additional context in comments.

1 Comment

Okay :( Then I have to look for some way to still do this (run code on commit if that table was changed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.