I'm trying to make the trigger for updating a view work. If I'm doing and INSERT it works! But when I'm trying to do an UPDATE it just doesn't run.
CREATE OR REPLACE FUNCTION test_trigger_function()
RETURNS trigger AS
$$
BEGIN
RAISE NOTICE 'hi';
RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;
CREATE TRIGGER test_trigger
INSTEAD OF INSERT OR UPDATE
ON specific_view
FOR EACH ROW
EXECUTE PROCEDURE test_trigger_function();
Then in another place I execute it:
RAISE NOTICE 'before';
UPDATE specific_view SET gender='randomstuff';
RAISE NOTICE 'after';
The result:
psql:test_function.pgsql:134: NOTICE: before
psql:test_function.pgsql:134: NOTICE: after
On INSERT:
RAISE NOTICE 'before';
INSERT INTO specific_view (gender)
VALUES ('randomstuff');
RAISE NOTICE 'after';
Returns:
psql:test_function.pgsql:134: NOTICE: before
psql:test_function.pgsql:134: NOTICE: hi
CONTEXT: SQL statement "INSERT INTO specific_view (gender)
VALUES ('randomstuff')"
PL/pgSQL function ... blahblahblah ... line 261 at SQL statement
psql:test_function.pgsql:134: NOTICE: after