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

Re: Right way to reject INSERTs and UPDATEs

From: Richard Huxton <dev(at)archonet(dot)com>
To: Dmitry Teslenko <dteslenko(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Right way to reject INSERTs and UPDATEs
Date: 2008-07-29 10:33:03
Message-ID: 488EF1DF.4030804@archonet.com (view raw or flat)
Thread:
Lists: pgsql-general
Dmitry Teslenko wrote:
> These solution work and enforce data integrity as needed. Sadly, database
> interface I use (Trolltech Qt 3) can't track when trigger aborts
> update or insert. Can I raise exception in trigger or something?

RAISE EXCEPTION 'Failed to update mytable: date range (%,%) overlaps an 
existing entry', NEW.from_dt, NEW.to_dt;

You can also do RAISE NOTICE, WARNING etc. See the pl/pgsql section of 
the manual for details.

-- 
   Richard Huxton
   Archonet Ltd

In response to

pgsql-general by date

Next:From: hubert depesz lubaczewskiDate: 2008-07-29 10:42:30
Subject: Re: Right way to reject INSERTs and UPDATEs
Previous:From: Dmitry TeslenkoDate: 2008-07-29 10:25:21
Subject: Right way to reject INSERTs and UPDATEs

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