Re: creating array of integer[] out of query - how?

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: creating array of integer[] out of query - how?
Дата
Msg-id 20090902100333.GN5407@samason.me.uk
обсуждение исходный текст
Ответ на Re: creating array of integer[] out of query - how?  ("Massa, Harald Armin" <chef@ghum.de>)
Ответы Re: creating array of integer[] out of query - how?  ("Massa, Harald Armin" <chef@ghum.de>)
Список pgsql-general
On Wed, Sep 02, 2009 at 11:50:38AM +0200, Massa, Harald Armin wrote:
>   select array(
> >  select x from (
> >  select array[2,3] as a
> >  union
> >  select array[3,4] as a ) x);
> >
> > ERROR:  could not find array type for datatype record
>
> ... I remember being there before :( arrays of rows are also not available.

Doh, sorry I forgot that that's an 8.4 only.  Before that you must
create your own composite type.

> To all: is there a deeper reason why there is no array type for datatype
> record available?

Not enough demand :)

>   [1] http://www.postgresql.org/docs/current/static/sql-createtype.html
> >
> > Thanks for the hint with CREATE TYPE, especially the lines
>
> """
> Whenever a user-defined type is created, PostgreSQL automatically creates an
> associated array type,
> """
> fills me with joy. ;)

Try:

  CREATE TYPE intarr AS (arr int[]);
  SELECT array(
    SELECT x::intarr FROM (
      SELECT array[2,3]
      UNION ALL
      SELECT array[3,4]) x(a));

and it should do the right thing in 8.3.

--
  Sam  http://samason.me.uk/

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

Предыдущее
От: "Massa, Harald Armin"
Дата:
Сообщение: Re: creating array of integer[] out of query - how?
Следующее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: Ungooglable error message when running initdb: Symbol not found: _check_encoding_conversion_args