Re: Intentionally produce Errors

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Andreas Seltenreich <andreas+pg(at)gate450(dot)dyndns(dot)org>
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, Matthias(dot)Pitzl(at)izb(dot)de, pgsql-general(at)postgresql(dot)org
Subject: Re: Intentionally produce Errors
Date: 2006-10-10 07:48:41
Message-ID: 452B5059.1030801@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andreas Seltenreich wrote:
> Markus Schiltknecht writes:
>> Matthias(dot)Pitzl(at)izb(dot)de wrote:

> --8<---------------cut here---------------start------------->8---
> create function error(text) returns void as $$
> begin
> raise exception '%', $1;
> end
> $$ language plpgsql;
> --8<---------------cut here---------------end--------------->8---
>
> However,
>
> ,----[ (info "(postgres)Errors and Messages") ]
> | `RAISE EXCEPTION' presently always generates the same SQLSTATE code,
> | `P0001', no matter what message it is invoked with.
> `----

That could be fixed by adding an error code to your function and putting
that in a recognizable place in your exception text. Not pretty, but it
should do the job.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2006-10-10 07:52:28 Re: plpgsql handling a set of values
Previous Message Merlin Moncure 2006-10-10 06:44:04 Re: Newbie question about importing text files...