Hi

2016-12-09 16:05 GMT+01:00 VENKTESH GUTTEDAR <venkteshgutte...@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.
>
>

Reply via email to