pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ShuA <noface@inbox.ru>
To: pgsql-sql@postgresql.org
Subject: Need a script that bakes INSERT script from SELECT results
Date: Thu, 16 Apr 2009 14:29:38 +0300
Message-ID: <E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru>
Permalink:  ../E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru/
Also on:    postgresql.org/message-id/E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru

 · 

reply

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: noface@inbox.ru
  Subject: Re: Need a script that bakes INSERT script from SELECT results
  In-Reply-To: <E1LuPmk-0008aN-00.noface-inbox-ru@f4.mail.ru>

* 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