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

From Pavel Stehule
Subject Re: [GENERAL] Multidimentional array access
Date
Msg-id CAFj8pRD_W-gUgc0MHhYw2vs7zp8pm0o2JEe2LgMub+nPq=xoWw@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Multidimentional array access  (VENKTESH GUTTEDAR <venkteshguttedar@gmail.com>)
List pgsql-general
Hi

2016-12-09 16:05 GMT+01:00 VENKTESH GUTTEDAR <venkteshguttedar@gmail.com>:
Hello,

    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

    Help would be appreciated.

postgres=# do
$$
declare i int; j int; a int[];
begin
  a := ARRAY[[1,2],[3,4]];
  for i in array_lower(a,1) .. array_upper(a,1)
  loop
    for j in array_lower(a,2)..array_upper(a,2)
    loop
      raise notice 'a[%,%]=%', i,j,a[i][j];
    end loop;
  end loop;
end;
$$;
NOTICE:  a[1,1]=1
NOTICE:  a[1,2]=2
NOTICE:  a[2,1]=3
NOTICE:  a[2,2]=4
DO
Time: 142,078 ms

What is your PostgreSQL version?

Regards

Pavel

 


--
Regards :
Venktesh Guttedar.


pgsql-general by date:

Previous
From: VENKTESH GUTTEDAR
Date:
Subject: [GENERAL] Multidimentional array access
Next
From: Merlin Moncure
Date:
Subject: Re: [GENERAL] When to use COMMENT vs --