我正在编写一个触发器,我需要将NEW行转换为json并插入到另一个表中。我说得不对。
CREATE OR REPLACE FUNCTION public.eventlogs_add_user()
RETURNS trigger AS
$BODY$
DECLARE newRecord JSON;
BEGIN
newRecord := row_to_json(row)
from (NEW) row;
// Insert newRecord into another table
RETURN NEW;
END$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION public.eventlogs_add_user()
OWNER TO postgres;
-----------------------------------------------------------
答案 0 :(得分:1)
更改
newRecord := row_to_json(row)
from (NEW) row;
到
newRecord := row_to_json(NEW.*);
应该帮助