Re: How to loop through multi-dimentional array in PL/PGSQL

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: VENKTESH GUTTEDAR <venkteshguttedar(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to loop through multi-dimentional array in PL/PGSQL
Date: 2016-12-09 10:42:10
Message-ID: d10b22de-92f4-2828-d8e2-08d16f79abe6@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/12/16 06:35, VENKTESH GUTTEDAR wrote:
> Hello,
>
> Please help me in accessing multi-dimentional array in postgresql
> PL/PGSQL.
>
> for i in array_lower(product_list, 1) .. array_upper(product_list, 1)
> LOOP
> product_list[i][0];
> END LOOP;
>
> Is the above code right?
>
> Or is there any other way to access, i am getting null for
> product_list[i][0];

By default, PostgreSQL uses 1-based arrays (i.e. no [0] slot), so maybe
that's your problem.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2016-12-09 10:47:15 Re: How to loop through multi-dimentional array in PL/PGSQL
Previous Message Shreeyansh Dba 2016-12-09 09:56:14 Re: [ADMIN] Would like to below scenario is possible for getting page/block corruption