Re[2]: Need a script that bakes INSERT script from SELECT results

Поиск
Список
Период
Сортировка
От ShuA
Тема Re[2]: Need a script that bakes INSERT script from SELECT results
Дата
Msg-id E1LuRZV-0007OW-00.noface-inbox-ru@f242.mail.ru
обсуждение исходный текст
Ответ на Re: Need a script that bakes INSERT script from SELECT results  (John DeSoi <desoi@pgedit.com>)
Ответы Re[3]: Need a script that bakes INSERT script from SELECT results  (ShuA <noface@inbox.ru>)
Список pgsql-sql
-----Original Message-----
From: John DeSoi <desoi@pgedit.com>
To: ShuA <noface@inbox.ru>
Date: Thu, 16 Apr 2009 08:25:15 -0400
Subject: Re: [SQL] Need a script that bakes INSERT script from SELECT results

> 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.

The functionality I need is about to replicate table data into remote DB.

>     for rec in select * from whatever loop
>         insert into some_table values (rec.*);
>     end loop;

^^^ that is not my case, unfortunately.

The next, what is supposed to do with baked INSERT statements, is push them thru dblink_exec(), as text param, to make
insertworks on remote DB. 

Olksy




В списке pgsql-sql по дате отправления:

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Need a script that bakes INSERT script from SELECT results
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Ordering a name list and ignoring whitespace