Create array of data from JSONB in PG 9.5

From: Arup Rakshit <ar(at)zeit(dot)io>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Create array of data from JSONB in PG 9.5
Date: 2019-11-15 10:01:26
Message-ID: FC8846FB-B521-499C-B07A-87DE5A22802C@zeit.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I wrote the below SQL which works and give me what I want, but it doesn’t work in 9.5 version. I wrote this query in PG 10. I want to change it so that I can run it on 9.5 as production using 9.5 version. I need help on this.

SELECT DISTINCT
ARRAY [jsonb_array_elements(data) ->> 'group', jsonb_array_elements(jsonb_array_elements(data) -> 'properties') ->> 'name']
FROM
"vessels"
WHERE
"vessels"."deleted_at" IS NULL
AND "vessels"."company_id" = '7d105acd-be5a-4225-a2db-b549105e4172';

When I ran the same query to production I get error:

ERROR: set-valued function called in context that cannot accept a set

Thanks,

Arup Rakshit
ar(at)zeit(dot)io

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrei Zhidenkov 2019-11-15 10:49:50 Race condition while creating a new partition
Previous Message Pavel Stehule 2019-11-15 05:41:35 Re: PostGreSQL Replication and question on maintenance