INSERT with a composite columnt from query

From: Reg Me Please <regmeplease(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: INSERT with a composite columnt from query
Date: 2008-01-16 10:39:54
Message-ID: 200801161139.55072.regmeplease@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all.

I have two table like these:

create table compo (
t text,
i int
);

create table tab (
x int,
c compo
);

Then I have a function like this:

create or replace function f_compo()
returns setof compo as $body$
...
$body$ language sql stable;

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

Any hint?

TALIA

--
Reg me, please!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2008-01-16 11:24:37 Re: INSERT with a composite columnt from query
Previous Message Clodoaldo 2008-01-16 10:32:50 Re: ATTN: Clodaldo was Performance problem. Could it be related to 8.3-beta4?