Trapping errors

Поиск
Список
Период
Сортировка
От Shane W
Тема Trapping errors
Дата
Msg-id 20110523200807.GA29846@csy.ca
обсуждение исходный текст
Ответы Re: Trapping errors
Re: Trapping errors
Список pgsql-general
Hello list,

I have a table with double precision columns and update
queries which multiply and divide these values. I am
wondering if it's possible to catch overflow and underflow
errors to set the column to 0 in the case of an underflow
and a large value in the case of an overflow.

Currently, I have an exception handler in a PLPGSQL
ufunction that sort of does this.

begin
update tbl set score = score/s
exception when numeric_value_out_of range then
update tbl set score=0
where cast(score/s as numeric) < 1e-200
end;

But this is messy since the exception needs to rescan the
entire table if even one row fails the update. Is there a
better way to do this?

Best,
Shane


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

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Postgre Client only Install on Linux- 8.4.7
Следующее
От: "David Johnston"
Дата:
Сообщение: Re: Trapping errors