plpgsql and setting array values.

Поиск
Список
Период
Сортировка
От Nicolai Petri
Тема plpgsql and setting array values.
Дата
Msg-id 005901c2f252$824427e0$3b99a483@lisatorris
обсуждение исходный текст
Ответы Re: plpgsql and setting array values.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi all

I'm writing a rrdtool replacement in pgsql and have a little problem with
plpgsql and arrays.

The problem is best shown in the following example :

--------------------------
CREATE OR REPLACE FUNCTION test1(integer[]) RETURNS float[] AS '
DECLARE
pa_dsid ALIAS FOR $1;
l_rv float[];
BEGIN
FOR aoffset IN 2 .. pa_dsid[1]+1 LOOP
-- XXX: The following is not possible..
l_rv[aoffset]:=pa_dsid[aoffset]*4; -- Return dummyvalue (multiply by 4)
END LOOP;
RETURN l_rv;
END;
' language 'plpgsql';
--------------------------

The problem is that i cannot assign values to explicit array values like
myarray[2]:=123;
The only way is to say myarray:=' {12,123}'; and that is not very flexible
because I will have to build up textstrings in my stored procedure.

Any comments on this ? Have I missed some documentation or similar ?

Best regards,
Nicolai Petri
catpipe Systems ApS


В списке pgsql-general по дате отправления:

Предыдущее
От: Richard Welty
Дата:
Сообщение: Re: fairly current mysql v postgresql comparison need for
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: fairly current mysql v postgresql comparison need for