Re: array/function question

Поиск
Список
Период
Сортировка
Искать
От
Pavel Stehule
Тема
Re: array/function question
Дата
в 13:00:19
Msg-id
162867790905190556o47563938i4b024a6a3d0aa5c1@mail.gmail.com
Ответ на
Список
Дерево обсуждения
array/function question Joshua Berry <yoberi@gmail.com>
Re: array/function question Pavel Stehule <pavel.stehule@gmail.com>
Re: array/function question Alvaro Herrera <alvherre@commandprompt.com>
Re: array/function question Pavel Stehule <pavel.stehule@gmail.com>
Re: array/function question Alvaro Herrera <alvherre@commandprompt.com>
Re: array/function question Nagy Zoltan <kirk@bteam.hu>
Re: array/function question Joshua Berry <yoberi@gmail.com>
Re: array/function question Alvaro Herrera <alvherre@commandprompt.com>
2009/5/19 Alvaro Herrera :
> Pavel Stehule escribió:
>
>> postgres=# create or replace function xx(anyarray, anyarray) returns
>> bool[] as $$
>> select array(select (select x = any(select y from unnest($2) g2(y)))
>> from unnest($1) g(x))
>> $$ language sql immutable;
>> CREATE FUNCTION
>
> There ain't no unnest() function in 8.3 ...

I am sorry

create or replace function unnest(anyarray) returns setof anyelement as $$
select $1[i] from generate_series(array_lower($1,1), array_upper($1,1)) g(i)
$$ language sql immutable;

when I looked on my code, it could be simplified

>> postgres=# create or replace function xx(anyarray, anyarray) returns
>> bool[] as $$
>> select array(select (select x = any($2)))
>> from unnest($1) g(x))
>> $$ language sql immutable;

regards
Pavel Stehule

>
> --
> Alvaro Herrera                                http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
В списке pgsql-general по дате отправления
От: hubert depesz lubaczewski
Дата:
От: David Fetter
Дата:
FAQ