douyalin2258
2019-02-25 09:27
浏览 523
已采纳

如何在postgresql 9.6中将json数组作为函数参数传递

--Takes a json array to parse each elements as text .But it shows an error. --Change the type from json[] to json but not helps.

CREATE OR REPLACE FUNCTION public.test(in_param json[])
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE 
AS $BODY$
declare 
 item text;
 arr1 text[];
 begin 
   for item in select * from json_array_elements_text(in_param ) loop
   arr1 = arr1||item;
   end loop;
return 0;
end;
$BODY$;
ALTER FUNCTION public.test(json[])
OWNER TO postgres;

2条回答 默认 最新

相关推荐 更多相似问题