Re: [GENERAL] Trapping errors

2011-05-24 Thread Alban Hertroys
On 23 May 2011, at 22:08, Shane W wrote: > 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

Re: [GENERAL] Trapping errors

2011-05-23 Thread David Johnston
UPDATE tbl SET score = divide_double_default(score, s, 1e-200) ... UPDATE tbl SET score = multiply_double_default(score, s, 9) ... Code the divide_double_default/multiply_double_default functions with error handling that will return the desired value (either zero or the supplied paramete

Re: [GENERAL] Trapping errors from pl/perl (trigger) functions

2007-07-01 Thread Wiebe Cazemier
On Sunday 01 July 2007 21:50, Tom Lane wrote: > Why would you expect it to? The raise_exception SQLSTATE applies > specifically and solely to the plpgsql RAISE command. The entire > point of those identifiers is to match fairly narrow classes of > exceptions, not anything thrown by anyone. > >

Re: [GENERAL] Trapping errors from pl/perl (trigger) functions

2007-07-01 Thread Michael Fuhr
On Sun, Jul 01, 2007 at 03:50:09PM -0400, Tom Lane wrote: > IMHO the real problem with both RAISE and the plperl elog command > is there's no way to specify which SQLSTATE to throw. In the case > of the elog command I think you just get a default. That default is XX000 (internal_error): test=> c

Re: [GENERAL] Trapping errors from pl/perl (trigger) functions

2007-07-01 Thread Tom Lane
Wiebe Cazemier <[EMAIL PROTECTED]> writes: > When I do something on the table which the trigger function prevents, I get a > message saying ERROR: blablabla. When such an error is generated by a pl/pgsql > trigger function, I can trap the error with WHEN raise_exception. This does > not work for th

Re: [GENERAL] Trapping errors from pl/perl (trigger) functions

2007-07-01 Thread Wiebe Cazemier
On Sunday 01 July 2007 21:16, Michael Fuhr wrote: > What have you tried and how did the outcome differ from your > expectations? The pl/perl trigger function in question generates an exception by elog(ERROR, "message"). I also tried die(), which didn't make a difference. When I do something on t

Re: [GENERAL] Trapping errors from pl/perl (trigger) functions

2007-07-01 Thread Michael Fuhr
On Sat, Jun 30, 2007 at 10:30:32PM +0200, Wiebe Cazemier wrote: > I have a pl/perl trigger function which can give an error, and I would like to > catch it in a pl/pgsql function, but I can't seem to trap it. What have you tried and how did the outcome differ from your expectations? > Is it possi

Re: [GENERAL] trapping errors in plpgsql?

2005-11-01 Thread Teguh R
CSN wrote: I have a table like so: id|username|email with unique indices on username and email. In a plpgsql function if an insert fails because of a duplicate on one of those fields, is it possible to trap the error, figure out which unique fields it applies to, and raise a custom error messag