Re: Intentionally produce Errors

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Intentionally produce Errors
Дата
Msg-id 452B5059.1030801@magproductions.nl
обсуждение исходный текст
Ответ на Re: Intentionally produce Errors  (Andreas Seltenreich <andreas+pg@gate450.dyndns.org>)
Список pgsql-general
Andreas Seltenreich wrote:
> Markus Schiltknecht writes:
>> Matthias.Pitzl@izb.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@magproductions.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 //

В списке pgsql-general по дате отправления:

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: Newbie question about importing text files...
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: plpgsql handling a set of values