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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-general by date

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