Re: INSERT with a composite columnt from query

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: INSERT with a composite columnt from query
Дата
Msg-id 478DE9C7.8090006@archonet.com
обсуждение исходный текст
Ответ на INSERT with a composite columnt from query  (Reg Me Please <regmeplease@gmail.com>)
Список pgsql-general
Reg Me Please wrote:
>
> What I'd need to do is to insert the results from f_compo() into
> the table TAB along with a value x.
>
> I expected somthing like this to work:
>
> insert into tab
>   select 42,row( c.* ) from f_compo() c;
>
> But I get
> ERROR:  cannot cast type record to compo

You need to add an explicit cast I believe.

INSERT INTO tab (x,c)
SELECT 42, ROW(c.*)::compo FROM f_compo() c;

Why you don't in the case of INSERT ... VALUES isn't immediately clear
to me.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Stefan Schwarzer
Дата:
Сообщение: Re: Forgot to dump old data before re-installing machine
Следующее
От: João Paulo Zavanela
Дата:
Сообщение: Re: Search connections created per day