Re: custom error messages/numbers

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: BARTKO Zoltan <bartko(dot)zoltan(at)pobox(dot)sk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: custom error messages/numbers
Date: 2004-05-27 20:42:49
Message-ID: 20040527204249.GA30462@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, May 27, 2004 at 06:26:53PM +0200, BARTKO Zoltan wrote:
> Folks,
>
> I am developing an app for PostgreSQL, entirely with stored functions (somewhat resembling the object-oriented approach. In fact it is not an app, just an API). All my functions return an integer value - 0 if the function was successful, another value otherwise.
>
> Until now, all parameter checking was done manually in the stored function (if param is null then return -8; end if; etc.) This makes things quite lengthy.
>
> I know about check constraints. However, upon error they throw an error message and abort the current transaction, So my question is: is there any possible way of throwing my own error messages upon a check constraint violation?

I don't know if this does what you want, but maybe RAISE ERROR is what
you're looking for.

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Postgresql 2004-05-27 21:39:19 PostgreSQL Logs
Previous Message Sally Sally 2004-05-27 20:30:53 pg_restore quick question