pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gnanavel S <s.gnanavel@gmail.com>
To: Dongsoo Yoon <dsyoon@metasoftworks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Error when using array variable
Date: Fri, 22 Jul 2005 15:07:04 +0530
Message-ID: <eec3b03c050722023774783b91@mail.gmail.com> (raw)
In-Reply-To: <000601c58e9f$1a3d0cc0$2d216b3d@notebook04>
References: <000601c58e9f$1a3d0cc0$2d216b3d@notebook04>

On 7/22/05, Dongsoo Yoon <dsyoon@metasoftworks.com> wrote:
> 
>  
> I use a function using array variable as following.
>  The function returns array type.
>  When array variable is allocated with any value,
> allocating is not done.
>  I can't find why it is.
>  -------------------------------------------------------
>  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.

v_testval := t_modifiedTimes[v_dayIndex ] ; -------------->¹è¿­¿¡ ÀúÀåµÈ °ª ÀÓ½ÃÀúÀå
>   raise exception 'ÀÓÀÇ¿¡·¯»ý¼º t_modifiedTimes[v_dayIndex ]=', v_testval ;
>   -------------->°­Á¦ÀûÀ¸·Î exception ¹ß»ý½ÃÅ´
>   end loop; 
>   ....
>   return t_modifiedTimes;
>    END; 
> $BODY$ LANGUAGE plpgsql; 
> 



-- 
with regards,
S.Gnanavel
Satyam Computer Services Ltd.


view thread (6+ messages)  latest in thread

Message-ID: <eec3b03c050722023774783b91@mail.gmail.com>
Permalink:  ../eec3b03c050722023774783b91@mail.gmail.com/
Also on:    postgresql.org/message-id/eec3b03c050722023774783b91@mail.gmail.com

 · 

reply

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: s.gnanavel@gmail.com, dsyoon@metasoftworks.com
  Subject: Re: Error when using array variable
  In-Reply-To: <eec3b03c050722023774783b91@mail.gmail.com>

* 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