From: Michael Fuhr <mike@fuhr.org>
To: Gnanavel S <s.gnanavel@gmail.com>
Cc: Dongsoo Yoon <dsyoon@metasoftworks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Error when using array variable
Date: Fri, 22 Jul 2005 17:38:58 -0600
Message-ID: <20050722233858.GA47991@winnie.fuhr.org> (raw)
In-Reply-To: <eec3b03c050722023774783b91@mail.gmail.com>
References: <000601c58e9f$1a3d0cc0$2d216b3d@notebook04>
<eec3b03c050722023774783b91@mail.gmail.com>
On Fri, Jul 22, 2005 at 03:07:04PM +0530, Gnanavel S wrote:
> On 7/22/05, Dongsoo Yoon <dsyoon@metasoftworks.com> wrote:
> > CREATE OR REPLACE FUNCTION arr_test()
> > RETURNS NUMERIC[] AS $BODY$
> > DECLARE
> > v_count NUMERIC default 0;
> > v_dayIndex NUMERIC default 0;
> > t_modifiedTimes NUMERIC[];
> > v_testval NUMERIC default 0;
> > ....
> > BEGIN
> > ....
> > for v_count in 1..5 loop
> > v_dayIndex := v_dayIndex + 1;
> >
> t_modifiedTimes[v_dayIndex ] := v_count;
>
> You need to initialse the array, Otherwise any value added to the array will
> be null.
This isn't necessary in 8.0, which we can infer is being used because
of the dollar quotes. See the 8.0 Release Notes:
http://www.postgresql.org/docs/8.0/static/release-8-0.html
"Updating an element or slice of a NULL array value now produces a
non-NULL array result, namely an array containing just the assigned-to
positions."
I don't recall if early 8.0 versions had any bugs in this respect,
but it does indeed work in 8.0.3.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, s.gnanavel@gmail.com, dsyoon@metasoftworks.com
Subject: Re: Error when using array variable
In-Reply-To: <20050722233858.GA47991@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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