Re: copy a record from one table to another (archive)

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, juerg(dot)rietmann(at)pup(dot)ch
Subject: Re: copy a record from one table to another (archive)
Date: 2001-03-14 13:02:28
Message-ID: 20010314130228.1EE491A67@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at){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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message pgsql-sql 2001-03-14 13:10:19 Re(2): Permissons on database
Previous Message Richard Huxton 2001-03-14 09:54:33 Re: my pgsql error?