po 14. 8. 2023 v 11:32 odesílatel Alvaro Herrera <alvhe...@alvh.no-ip.org>
napsal:

> On 2023-Aug-14, Pavel Stehule wrote:
>
> > jsonb_populate_array(anyarray, jsonb) returns anyarray
> >
> > Usage:
> >
> > select jsonb_populate_array(null::text[],
> '["cust_full_name","cust_email"]')
>
> I don't understand what this does.  Can you be more explicit?
>

example

'["2023-07-13","2023-07-14"]'::jsonb -->  {2023-07-13,2023-07-14}::date[]

Now, I have to transform to table, casting, and back transformation to
array, and I cannot to write generic function. I can run just "slow" query

select array_agg(value::date) from
jsonb_array_elements_text('["2023-07-13","2023-07-14"]'::jsonb);

with proposed function I can write

select jsonb_populate_array(null:date[],
'["2023-07-13","2023-07-14"]'::jsonb)

Regards

Pavel



> --
> Álvaro Herrera               48°01'N 7°57'E  —
> https://www.EnterpriseDB.com/
> Maybe there's lots of data loss but the records of data loss are also lost.
> (Lincoln Yeoh)
>

Reply via email to