【发布时间】:2017-02-28 09:35:05
【问题描述】:
函数json_object_keys(json) 返回一个setof text。如何将此 setof text 转换为所有元素由 ',' 分隔的字符串?我必须使用函数array_to_string(),但它接受一个数组,而不是setof。那么如何将setof 转换为数组。例如:
DECLARE
custom_fields json;
BEGIN
custom_fields:='{"name":"John Smith","age":23}';
keys:=array_to_string(json_object_keys(custom_fields),','::text);
END
以上不起作用,我得到:
ERROR: function array_to_string(text, text) does not exist
那么,如何将SETOF 转换为ARRAY?
【问题讨论】:
标签: postgresql plpgsql