Re: [GENERAL] Multidimentional array access - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] Multidimentional array access
Date
Msg-id 16814.1481297439@sss.pgh.pa.us
Whole thread Raw
In response to [GENERAL] Multidimentional array access  (VENKTESH GUTTEDAR <venkteshguttedar@gmail.com>)
Responses Re: [GENERAL] Multidimentional array access
List pgsql-general
VENKTESH GUTTEDAR <venkteshguttedar@gmail.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


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: [GENERAL] When to use COMMENT vs --
Next
From: Merlin Moncure
Date:
Subject: Re: [GENERAL] storing C binary array in bytea via libpq