Postgres triggers that notify and then listen for a response on a channel?

361 views Asked by At

I'm looking for a way to do a request response pattern inside a trigger. This would be used to perform additional (more complex) data validation.

More concretely, something like this:

CREATE OR REPLACE TRIGGER create_user
BEFORE INSERT
   ON users
   FOR EACH ROW
BEGIN
  --- trigger 3rd party validation code
  NOTIFY creating new.user

  --- listen for 3rd party code to notify with the result
  return LISTEN created

END;

Would this be possible to do in postgres? Thanks!

0

There are 0 answers