Thread: working with multidimensional arrays in plpgsql

working with multidimensional arrays in plpgsql

From
Sibtay Abbas
Date:
hello everyone

i am having problem with multidimensional arrays in plpgsql following
is the source code of the function which i am trying to run

CREATE OR REPLACE FUNCTION test() RETURNS VOID AS $$
DECLARE
x INTEGER[10][10];
tmp VARCHAR(40);
BEGIN
x[3][1] := '20';               ------i have even tried x[3][1] = 20
tmp := x[3][1];
RAISE NOTICE '%', tmp;
RETURN;
END;
$$LANGUAGE 'plpgsql';

As you might have observed here, the actual problem is
how to do assignment to multidimensional array locations using the
subscript operater.

Thank you

Re: working with multidimensional arrays in plpgsql

From
Sibtay Abbas
Date:
On Wed, 26 Jan 2005 12:40:24 +0500, Sibtay Abbas <sibtay@gmail.com> wrote:
> hello everyone
>
> i am having problem with multidimensional arrays in plpgsql following
> is the source code of the function which i am trying to run
>
> CREATE OR REPLACE FUNCTION test() RETURNS VOID AS $$
> DECLARE
> x INTEGER[10][10];
> tmp VARCHAR(40);
> BEGIN
> x[3][1] := '20';               ------i have even tried x[3][1] = 20
> tmp := x[3][1];
> RAISE NOTICE '%', tmp;
> RETURN;
> END;
> $$LANGUAGE 'plpgsql';
>
> As you might have observed here, the actual problem is
> how to do assignment to multidimensional array locations using the
> subscript operater.
>
> Thank you
>

Something which i forgot to mention is that the output of the above
mentioned procedure is
NOTICE: NULL

which means and x[3][1] was not initiliazed with the statement
x[3][1] := '20';