Wiebe Cazemier <halfgaar@xxxxxxx> 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 the exception generated by the pl/perl function. 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. 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. regards, tom lane