From: John DeSoi <desoi@pgedit.com>
To: ShuA <noface@inbox.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: Need a script that bakes INSERT script from SELECT results
Date: Thu, 16 Apr 2009 08:25:15 -0400
Message-ID: <5CDAA3CE-6B0F-4177-A5E1-241584EB6A90@pgedit.com> (raw)
In-Reply-To: <E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru>
References: <E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru>
On Apr 16, 2009, at 7:29 AM, ShuA wrote:
> Could someone post an example how to LOOP through row fields to wrap
> them into 'VALUES(...,,)' list?
If you declare record or table row types, you can insert the values
using (rec.*), something like this:
create or replace function test ()
returns void as $$
declare
rec record;
begin
for rec in select * from whatever loop
insert into some_table values (rec.*);
end loop;
end;
$$ language plpgsql;
John DeSoi, Ph.D.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: desoi@pgedit.com, noface@inbox.ru
Subject: Re: Need a script that bakes INSERT script from SELECT results
In-Reply-To: <5CDAA3CE-6B0F-4177-A5E1-241584EB6A90@pgedit.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox