Error when using array variable

From: "Dongsoo Yoon" <dsyoon(at)metasoftworks(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Error when using array variable
Date: 2005-07-21 09:29:29
Message-ID: 002101c58dd6$b1d8cb60$2d216b3d@notebook04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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;

v_testval := t_modifiedTimes[v_dayIndex ] ; -------------->배열에 저장된 값 임시저장

raise exception '임의에러생성 t_modifiedTimes[v_dayIndex ]=', v_testval ;

-------------->강제적으로 exception 발생시킴

end loop;

....

return t_modifiedTimes;

END;
$BODY$ LANGUAGE plpgsql;

Browse pgsql-sql by date

  From Date Subject
Next Message Ricky Sutanto 2005-07-21 10:33:32 Counting Row
Previous Message Neil Dugan 2005-07-21 04:16:32 Re: [SQL] dynamically loaded functions