pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arup Rakshit <ar@zeit.io>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Create array of data from JSONB in PG 9.5
Date: Fri, 15 Nov 2019 11:08:18 -0500
Message-ID: <28530.1573834098@sss.pgh.pa.us> (raw)
In-Reply-To: <FC8846FB-B521-499C-B07A-87DE5A22802C@zeit.io>
References: <FC8846FB-B521-499C-B07A-87DE5A22802C@zeit.io>

Arup Rakshit <ar@zeit.io> writes:
> 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

IIRC, you can't nest calls of set-returning functions before about v10.
One workaround is to put the inner set-returning function call into a
sub-select.

			regards, tom lane





view thread (3+ messages)

Message-ID: <28530.1573834098@sss.pgh.pa.us>
Permalink:  ../28530.1573834098@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28530.1573834098@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ar@zeit.io
  Subject: Re: Create array of data from JSONB in PG 9.5
  In-Reply-To: <28530.1573834098@sss.pgh.pa.us>
  References: <FC8846FB-B521-499C-B07A-87DE5A22802C@zeit.io> <28530.1573834098@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox