Re: Intentionally produce Errors - Mailing list pgsql-general

From Andreas Seltenreich
Subject Re: Intentionally produce Errors
Date
Msg-id 87slhxych3.fsf@gate450.dyndns.org
Whole thread Raw
In response to Re: Intentionally produce Errors  (Markus Schiltknecht <markus@bluegap.ch>)
Responses Re: Intentionally produce Errors
List pgsql-general
Markus Schiltknecht writes:

> Matthias.Pitzl@izb.de wrote:
>> In PL/pgSQL you could use the RAISE command:
>> http://www.postgresql.org/docs/8.1/interactive/plpgsql-errors-and-messages.h
>> tml
>
> Thank you, good to know. Unfortunately I'm not in a PL/PgSQL function,
> just a plain query. Some standard functions which invoke RAISE?

I don't think there is any.  Maybe wrapping `raise exception' with a
function would work for you?  I'm using the following function to
raise exceptions from plain sql.

--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.
`----

regards,
andreas

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: UTF-8
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Automatic locale detection?