How do I insert a record into a table?

From: Brian Hurt <bhurt(at)janestcapital(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: How do I insert a record into a table?
Date: 2007-06-01 18:31:48
Message-ID: 46606614.1020605@janestcapital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I want to write a query like:

INSERT INTO table SELECT func(args);

where func is defined as:

CREATE OR REPLACE FUNCTION func(args)
RETURNS table
AS $_$
...
$_$ LANGUAGE plpgsql;

Unfortunately, when I try to do this, I get:

ERROR: column "first_column" is of type integer but expression is of
type record

I get this error even if I list the columns:
INSTER INTO table(first_column, second_column, ...) ....

So how do I take a record returned from a function, and insert it as a
row into a table?

Brian

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesemann 2007-06-01 19:03:47 Re: How do I insert a record into a table?
Previous Message Tom Lane 2007-06-01 18:22:45 Re: assign null value to a field in plpgsql