Re: Custom Contraint Violation Errors

From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Michael Musenbrock <redeamer(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Custom Contraint Violation Errors
Date: 2011-11-07 15:06:18
Message-ID: CABvLTWHdBhzxzNVg5N8w6wMxev2BxFRE=UUJ5Ss-gvRLrcFiow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 3, 2011 at 11:56 PM, Michael Musenbrock <redeamer(at)gmx(dot)net> wrote:

> But I have not
> found any information if this is possible to create a trigger on a
> constraint violation, and if yes, how could that be done?

You want to use the special type of "CONSTRAINT" trigger.

http://www.postgresql.org/docs/9.1/interactive/sql-createtrigger.html

Notice that constraint triggers require the developer of the trigger
to RAISE EXCEPTION when the constraint is violated.

http://www.postgresql.org/docs/9.1/interactive/plpgsql-errors-and-messages.html

The syntax for RAISE EXCEPTION allow the developer to specify any
desired message.

--
Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ing.Edmundo.Robles.Lopez 2011-11-07 15:35:23 Why fetch a row is more slow than a 'selec * from'
Previous Message Ivan Sergio Borgonovo 2011-11-07 14:43:08 function doesn't see change in search_path