Search Postgresql Archives

Re: INSERT with a composite columnt from query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux