Re: plpgsql array initialization, what's the story?

Поиск
Список
Период
Сортировка
Искать
От
Karl O. Pinc
Тема
Re: plpgsql array initialization, what's the story?
Дата
Msg-id
1112306000l.15411l.3l@mofo
Ответ на
Список
Дерево обсуждения
plpgsql array initialization, what's the story? "Karl O. Pinc" <kop@meme.com>
Re: plpgsql array initialization, what's the story? Michael Fuhr <mike@fuhr.org>
Re: plpgsql array initialization, what's the story? "Karl O. Pinc" <kop@meme.com>

On 03/31/2005 01:59:02 PM, Michael Fuhr wrote:

> I think this has been fixed for 8.0.2:
> 
> http://archives.postgresql.org/pgsql-committers/2005-02/msg00012.php
> 
> Here's a test in 8.0.2beta1:
> 
> CREATE FUNCTION foo() RETURNS integer[] AS $$
> DECLARE
>     y  integer[];
> BEGIN
>     y[1] := 1;
>     y[2] := 2;
>     y[3] := 3;
> 
>     RETURN y;
> END;
> $$ LANGUAGE plpgsql;
> 
> SELECT foo();
>    foo
> ---------
>  {1,2,3}
> (1 row)
>

In the meantime, those who want arrays of non-integer datatypes
must cast to an array of the appropriate datatype (as suggested
by the documentation.)

create or replace function kop.bar()
returns date[]
language plpgsql
as $func$
declare
y date[] := CAST ('{}' AS date[]);

begin
y[1] := '1979-03-01';
y[2] := '1979-03-02';
y[3] := '1979-03-03';

return y;
end;
$func$;

Karl 
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein


В списке pgsql-general по дате отправления
От: Andrus
Дата:
От: Srikanth Utpala (Virinchi)
Дата:
FAQ