Re: How do I insert a record into a table?

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Brian Hurt <bhurt(at)janestcapital(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How do I insert a record into a table?
Date: 2007-06-01 19:03:47
Message-ID: 16040AEB-8892-40FA-937C-79CD7FE73354@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Jun 1, 2007, at 13:31 , Brian Hurt wrote:

>
> I want to write a query like:
>
> INSERT INTO table SELECT func(args);

I think you might want to try something along the lines of
INSERT INTO table (col1, col2, col3)
SELECT col1, col2, col3
FROM func(args);

Then again, you could wrap the whole insert into the function:

CREATE FUNCTION func(args)
RETURNS VOID
LANGUAGE plpgsql AS $_$
-- ...
INSERT INTO table (col1, col2, col3)...
$_$;

then SELECT func(args); to call the function.

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma Jr 2007-06-01 19:06:38 Re: How do I insert a record into a table?
Previous Message Brian Hurt 2007-06-01 18:31:48 How do I insert a record into a table?