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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: error handling



> --> I have a table with an UNIQUE constraint. Is it possible to have
> --> something like a trigger (or error handler) which is called every time
> --> a insert statement would break this constraint?  Or in some simple cases
> --> that this record is just dropped silently, without reporting an error?

> I believe that a UNIQUE constraint will stop the insert before any trigger 
> ever fires. Maybe someone else knows for sure.

I do not know if there is an specific error handler built in postgresql (besides error-codes).

If you break the unique constraint an error will be thrown. A
workaround may be to launch a trigger BEFORE the insertion and do whatever is necessary within the trigger.

http://www.postgresql.org/docs/8.1/static/sql-createtrigger.html

--
Oscar



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group