Re: Multidimentional array access

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: VENKTESH GUTTEDAR <venkteshguttedar(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multidimentional array access
Date: 2016-12-09 15:30:39
Message-ID: 16814.1481297439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

VENKTESH GUTTEDAR <venkteshguttedar(at)gmail(dot)com> writes:
> I want to get the inner array in a multi dimentional array in a
> pl/pgsql procedure.

> Eg : {{1,2,3,4,5,6,7},{11,22,33,44,55,66,77}}

> for i in array_lower(Eg, 1) .. array_upper(Eg, 1)
> LOOP
> array_value = Eg[i]
> END LOOP;

> But Eg[i] is assigning null to array_value

I think you want

array_value = Eg[i][array_lower(Eg, 2):array_upper(Eg, 2)]

As of 9.6 you could use the shorthand

array_value = Eg[i][:]

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2016-12-09 15:31:21 Re: storing C binary array in bytea via libpq
Previous Message Merlin Moncure 2016-12-09 15:23:19 Re: When to use COMMENT vs --