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

CHECK vs BEFORE trigger

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: CHECK vs BEFORE trigger
Date: 2005-04-22 19:29:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Hi All,

I am about to create a new table that will store among other things two
dimensions.  The user requires that the smaller of the two dimesions always be
referred to as the width.

As I see it I can either implement a CHECK constraint and handle the error or
implement a BEFORE INSERT OR UPDATE trigger that checks the two values and
switches them if necessary.

If I implement the trigger is there any point in implementing the CHECK?

In this simple situation is there any reason to implement the CHECK and not
use a trigger?

Your comments will be appreciated.

Kind Regards,


pgsql-novice by date

Next:From: Keith WorthingtonDate: 2005-04-22 20:20:51
Subject: char or int vs varchar
Previous:From: Van Ingen, LaneDate: 2005-04-22 16:59:55
Subject: Re: CHECK Constraints

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