E
E
EvilScream2019-10-01 16:30:39
PostgreSQL
EvilScream, 2019-10-01 16:30:39

Creating a function and trigger in Postgres?

Hello everyone, I created a function and a trigger:

CREATE OR REPLACE FUNCTION todos_notify_func() RETURNS TRIGGER AS $$
DECLARE
    BEGIN
        PERFORM pg_notify('users','my message text');
    RETURN NULL;
    END;
$$ LANGUAGE plpgsql;

CREATE  TRIGGER todos_notify_trig AFTER UPDATE ON users
FOR EACH ROW EXECUTE PROCEDURE todos_notify_func();

When I try to make a request: I get an error ERROR: control reached end of trigger procedure without RETURN CONTEXT: PL/pgSQL function todos_notify_func() Google says that there is no return function, but I have it. How can I fix this, I have a test, educational example.
UPDATE users SET username='pls' WHERE id = 1;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question