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

prevent an update from occurring under certain conditions

From: Carol Cheung <cacheung(at)consumercontact(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: prevent an update from occurring under certain conditions
Date: 2009-03-27 15:58:47
Message-ID: 49CCF7B7.1060709@consumercontact.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,
I'm not sure where to look for information about how to accomplish this:

TABLES
state:
  id | state_name | active
----+------------+--------
   1 | Washington | t
   2 | Illinois   | t

county:
  id | county_name | active | state_id
----+-------------+--------+----------
   1 | King        | t      |        1
   2 | Jefferson   | t      |        1

I want to prevent an update to set a state's active to false if there 
are any counties in that state that are active (county.active = true and 
county.state_id = state.id)
Is this possible?

Thanks in advance for your help.

Responses

pgsql-novice by date

Next:From: David SaraciniDate: 2009-03-27 18:21:10
Subject: Re: prevent an update from occurring under certain conditions
Previous:From: Ruzsinszky AttilaDate: 2009-03-25 09:38:43
Subject: pgAdminIII and pg_dump upgrade

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