Right way to reject INSERTs and UPDATEs - Mailing list pgsql-general

From Dmitry Teslenko
Subject Right way to reject INSERTs and UPDATEs
Date
Msg-id 91325fec0807290325h6bb80eb0g75f583d666fbe5d5@mail.gmail.com
Whole thread Raw
Responses Re: Right way to reject INSERTs and UPDATEs
Re: Right way to reject INSERTs and UPDATEs
List pgsql-general
Hello!
I have postgresql table that stores dome date range: it has range-begin
and range-end columns of type date. I want to enforce that 1) range-begin
would always before range-end and 2) there would be no range overlaps.

First problem could be solved with CHECK constraint. The only possibility
to solve second problem is to use a trigger. Trigger would fire
BEFORE INSERT OR UPDATE and FOR EACH ROW and invoke pgplsql function
that returns NULL or "new" depending on condition met or not;

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?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

pgsql-general by date:

Previous
From: "Asko Oja"
Date:
Subject: Re: Clone a database to other machine
Next
From: valgog
Date:
Subject: Re: array_accum() and quoted content