Re: Constraint, Rule, or Trigger? - Mailing list pgsql-general

From Joe Conway
Subject Re: Constraint, Rule, or Trigger?
Date
Msg-id 003701c12210$d7dc6190$0705a8c0@jecw2k1
Whole thread Raw
In response to Constraint, Rule, or Trigger?  (Randall Perry <rgp@systame.com>)
Responses Re: Constraint, Rule, or Trigger?  (Randall Perry <rgp@systame.com>)
List pgsql-general
> I've had experience with SQL and database design, but not much with rules
&
> triggers. What's the best method to accomplish the following it PGSQL:
>
> _Table A_ has a boolean field 'status'
>
> _Table B_ has a 1-1 child relationship to Table A.
>
> The rule, trigger, or contraint would have to enforce that: no record
could
> be created in B  if  the 'status' field was false in the parent record in
A
>
> Just point me in the right direction.
> Thanks
>

Well start here: http://www.postgresql.org/idocs/index.php?plpgsql.html
and in particular look at
http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html

Also, if you have the source tree available, look at

<path-to-pgsql-source>\src\pl\plpgsql\test\triggers.sql

for lots of examples.

Hope this helps,

-- Joe



pgsql-general by date:

Previous
From: Randall Perry
Date:
Subject: Constraint, Rule, or Trigger?
Next
From: Adam Sherman
Date:
Subject: Large Objects