pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: darcy@druid.net
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Cc: juerg.rietmann@pup.ch
Subject: Re: copy a record from one table to another (archive)
Date: Wed, 14 Mar 2001 08:02:28 -0500 (EST)
Message-ID: <20010314130228.1EE491A67@druid.net> (raw)
In-Reply-To: <004b01c0abc1$6bd78c60$1001a8c0@archonet.com>

Thus spake Richard Huxton
> begin;
>   insert into archive_foo (select * from foo where foo_id=1);
>   delete from foo where foo_id=1;
> commit;
> 
> Is probably the closest you could get.
> 
> Alternatively, you could wrap the above up in a function and just go:
> 
> select do_archive_foo(1);

Or even use a trigger if suitable.  You can have the delete automatically
trigger an insert into another table.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (3+ messages)

Message-ID: <20010314130228.1EE491A67@druid.net>
Permalink:  ../20010314130228.1EE491A67@druid.net/
Also on:    postgresql.org/message-id/20010314130228.1EE491A67@druid.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, dev@archonet.com, juerg.rietmann@pup.ch
  Subject: Re: copy a record from one table to another (archive)
  In-Reply-To: <20010314130228.1EE491A67@druid.net>
  References: <004b01c0abc1$6bd78c60$1001a8c0@archonet.com> <20010314130228.1EE491A67@druid.net>

* 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