Skip site navigation (1) Skip section navigation (2)

Re: popstgresql query

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Arun Gananathan <arun(at)gananathan(dot)fslife(dot)co(dot)uk>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: popstgresql query
Date: 2004-01-26 17:39:46
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On Mon, 19 Jan 2004, Arun Gananathan wrote:

> Hi,
> Could anyone please let me know how to perform the following in 
> postgresql
> I have two tables called P , Q  with the same attributes and data 
> tpyes. I want to insert a record ( for example called A) into table P, 
> when deleting the same record( for example  called A which is already in 
> the other table)  from the other table Q.

Pretty straight ahead.  You can either use a fancy trigger setup, or just 
do it in a transaction to ensure integrity:

insert into P (select * from Q where recid='A';
delete from Q where recid='A';

If the insert fails, the delete won't happen either.

That close to what you want?

In response to

pgsql-admin by date

Next:From: Reece HartDate: 2004-01-26 17:57:46
Subject: Re: "mirroring" a table - PostgreSQL 7.3.2
Previous:From: Cleiton BeckerDate: 2004-01-26 17:12:27
Subject: I want to quit

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group