Re: How do I insert a record into a table? - Mailing list pgsql-novice

From Michael Glaesemann
Subject Re: How do I insert a record into a table?
Date
Msg-id 16040AEB-8892-40FA-937C-79CD7FE73354@seespotcode.net
Whole thread Raw
In response to How do I insert a record into a table?  (Brian Hurt <bhurt@janestcapital.com>)
Responses Re: How do I insert a record into a table?  (Brian Hurt <bhurt@janestcapital.com>)
List 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



pgsql-novice by date:

Previous
From: Brian Hurt
Date:
Subject: How do I insert a record into a table?
Next
From: Richard Broersma Jr
Date:
Subject: Re: How do I insert a record into a table?