Re: Intentionally produce Errors

From: Andreas Seltenreich <andreas+pg(at)gate450(dot)dyndns(dot)org>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: Matthias(dot)Pitzl(at)izb(dot)de, pgsql-general(at)postgresql(dot)org
Subject: Re: Intentionally produce Errors
Date: 2006-10-09 11:07:04
Message-ID: 87slhxych3.fsf@gate450.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Markus Schiltknecht writes:

> Matthias(dot)Pitzl(at)izb(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-10-09 11:11:44 Re: Automatic locale detection?
Previous Message Martijn van Oosterhout 2006-10-09 10:41:59 Re: UTF-8