Need a script that bakes INSERT script from SELECT results

From: ShuA <noface(at)inbox(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Need a script that bakes INSERT script from SELECT results
Date: 2009-04-16 11:29:38
Message-ID: E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm a novice to PL/pgSQL, and I'm curious, how to write function, that wraps SELECT results into INSERT script.

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

I have tried dblink_build_insert(), but it requires primary key on tuple to create INSERT script from. I would prefer filter clause to primary key, to generate either multiple inserts or one multi-row insert.

Could someone post an example how to LOOP through row fields to wrap them into 'VALUES(...,,)' list?

Thanks,
Olksy

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John DeSoi 2009-04-16 12:25:15 Re: Need a script that bakes INSERT script from SELECT results
Previous Message Mario Splivalo 2009-04-16 11:02:44 Re: Ordering a name list and ignoring whitespace