pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedworking with multidimensional arrays in plpgsql
4+ messages / 3 participants
[nested] [flat]
* working with multidimensional arrays in plpgsql
@ 2005-01-26 07:02 Sibtay Abbas <sibtay@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Sibtay Abbas @ 2005-01-26 07:02 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: working with multidimensional arrays in plpgsql
@ 2005-01-26 09:29 Richard Huxton <dev@archonet.com>
parent: Sibtay Abbas <sibtay@gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: Richard Huxton @ 2005-01-26 09:29 UTC (permalink / raw)
To: Sibtay Abbas <sibtay@gmail.com>; +Cc: pgsql-sql
Sibtay Abbas 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
> DECLARE
> x INTEGER[10][10];
> x[3][1] := '20'; ------i have even tried x[3][1] = 20
> As you might have observed here, the actual problem is
> how to do assignment to multidimensional array locations using the
> subscript operater.
Actually, the problem is that the array "x" has been initialised to
NULL. Therefore, you can't set individual values. Try a line like:
x := '{}';
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: working with multidimensional arrays in plpgsql
@ 2005-01-26 11:06 Sibtay Abbas <sibtay@gmail.com>
parent: Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Sibtay Abbas @ 2005-01-26 11:06 UTC (permalink / raw)
To: Richard Huxton <dev@archonet.com>; +Cc: pgsql-sql
thank you very much for your reply
I did as you specified and it worked fine
thankz :)
On Wed, 26 Jan 2005 09:29:53 +0000, Richard Huxton <dev@archonet.com> wrote:
> Sibtay Abbas 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
>
>
> > DECLARE
> > x INTEGER[10][10];
>
> > x[3][1] := '20'; ------i have even tried x[3][1] = 20
>
> > As you might have observed here, the actual problem is
> > how to do assignment to multidimensional array locations using the
> > subscript operater.
>
> Actually, the problem is that the array "x" has been initialised to
> NULL. Therefore, you can't set individual values. Try a line like:
> x := '{}';
>
> --
> Richard Huxton
> Archonet Ltd
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: working with multidimensional arrays in plpgsql
@ 2005-01-26 18:05 Josh Berkus <josh@agliodbs.com>
parent: Sibtay Abbas <sibtay@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Josh Berkus @ 2005-01-26 18:05 UTC (permalink / raw)
To: pgsql-sql@postgresql.org, Sibtay Abbas <sibtay@gmail.com>
Sibtay,
> As you might have observed here, the actual problem is
> how to do assignment to multidimensional array locations using the
> subscript operater.
Maybe post your results, too?
--
Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-01-26 18:05 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-26 07:02 working with multidimensional arrays in plpgsql Sibtay Abbas <sibtay@gmail.com>
2005-01-26 09:29 ` Richard Huxton <dev@archonet.com>
2005-01-26 11:06 ` Sibtay Abbas <sibtay@gmail.com>
2005-01-26 18:05 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox