function to convert jsonb array into a string of text seperated by delimiter
This commit is contained in:
parent
0e6e7e45f4
commit
982b9bc284
20
postgres/jsonb_array_string_agg.sql
Normal file
20
postgres/jsonb_array_string_agg.sql
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
DROP FUNCTION IF EXISTS public.jsonb_array_string_agg;
|
||||||
|
CREATE FUNCTION public.jsonb_array_string_agg(_arr jsonb, _delim text) RETURNS text AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_ret text;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
string_agg(ae.v,_delim)
|
||||||
|
INTO
|
||||||
|
_ret
|
||||||
|
FROM
|
||||||
|
jsonb_array_elements_text(_arr) ae(v);
|
||||||
|
|
||||||
|
return _ret;
|
||||||
|
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
Loading…
Reference in New Issue
Block a user