Catching errors

From: CSN <cool_screen_name90001(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Catching errors
Date: 2004-06-23 22:54:25
Message-ID: 20040623225425.64697.qmail@web52905.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is it possible to "catch" errors in pl/pgsql? For
example, instead of the function exiting with (from an
INSERT attempt):

ERROR: duplicate key violates unique constraint
"user_name"
CONTEXT: PL/pgSQL function "add_user" line 12 at SQL
statement

The function could catch the error, then generate it's
own custom error message:

raise exception ''user name already exists'';

Thanks,
CSN


__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Thomas 2004-06-23 23:31:03 Re: pgHoster.com woes and looking for a new host
Previous Message Tom Lane 2004-06-23 21:52:34 Re: Dump produces file with new line characters