Subject Exceptions in Triggers - trying to signal multiple errors at once
Author albreingan
I write all my validation logic into a trigger for each table.

I am trying to implement a very useful feature of the database on an
IBM AS/400 which allowed a trigger to send a "message" for each error
found, followed by an exception which terminates the trigger.

This allowed applications to flag all (or at least most) errors at
once rather than the more common single exception at a time (which
tends to get frustrating).

I understand how to use a pair of UDF's to add to and retieve a list
of messages for each session, but I also need to revert to a single
exception at a time for those clients that cannot handle the messaging
(an IBExpert session for example).

This leads to very tortuous code with the two different actions spelt
out for every possible exception.

Am I missing something obvious? I've dug through the documentation but
found nothing likely.

Is there some other way to get this function?

If not is there any way of retieving the exception id or text in a
when clause?

Or possibly there is a way of singlaling a variable excpetion (for
example "exception :Exp" rather than "Exception NullItem"

Thank you in advance for any hints or help you can provide.