I'm using postgres 9.5, and defining a trigger to be run when a row is added to a table, something in the line of:
CREATE TRIGGER addedTrigger AFTER INSERT ON ships
FOR EACH ROW EXECUTE PROCEDURE added();
My added function is written in plpgsql, and its purpose is to fetch some data, assemble it into a certain format, and send over pg_notify to a channel. This is something resembling the body:
$$
BEGIN
PERFORM pg_notify('events', json_build_object('type', 'ADDED', 'userId', NEW.userId)::text);
RETURN NULL;
END;
$$
However, when the trigger runs, I get the following error message:
ERROR: record "new" has no field "userid"
CONTEXT: SQL statement "SELECT NEW.userId"
PL/pgSQL function added() line 5 at RAISE
Somehow the plpgsql function is downcasing my key annotation internally, and I'm not sure exactly how to proper use this, as all the examples I see in the wild are with non-primary-or-foreign-key attributes, and all of them are downcased.
friendregistered(), but you haveadded()in trigger - smth you dont tell us?.. - Vao TsunNEW.userId- if you have it indeed, then change toNEW."userId"- Vao Tsun