您好,我有 JSON 类型的列,我在其中存储例如 '{ "foo": 0 }' 现在我想编写触发器,它将是特定操作的增量值。我有问题,因为如果更新值不存在,我不知道如何增加或设置 0 值。我试图从这里编写类似于代码的函数:https ://stackoverflow.com/a/44563662/10999632但这是不可能的,因为:
ERROR: function jsonb_set(json, unknown, jsonb) does not exist
LINE 2: SET payload = jsonb_set(payload, '{bar}', (COALESCE(payload-...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.