Re: Updates and deletes with joins

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Updates and deletes with joins
Date: 2008-08-19 16:42:07
Message-ID: 200808190942.07937@hal.medialogik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 19 August 2008, Gordon <gordon(dot)mcvey(at)ntlworld(dot)com> wrote:
> I want to be able to restrict any query that updates or deletes from
> the articles table so that they can only occur if there isn't a
> corresponding entry in the locks table. As far as I can tell,
> however, you can't join tables when doing updates or deletes. I know
> on the PHP side I can attempt to do a select on the locks table and
> only perform the delete if the select returns 0 rows, but I'd rather
> the update or delete query itself does the checking. Can anyone help
> out?

The best way to implement this is through triggers on the target tables.

However, you can also do joins with updates and deletes (UPDATE ... FROM and
DELETE ... USING).

--
Alan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mark Roberts 2008-08-19 17:01:30 Re: What's size of your PostgreSQL Database?
Previous Message Tom Lane 2008-08-19 15:29:51 Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully