Sorry if I wasn't very precise.
I lost all my yesterday tryiing to resolve this problem.
I have a custom procedure handle_errors. I have a parameter in this procedure who stands for the original error value (which correspond to @@error in sql server and to sqlstate in DB2).
I would like to catch the sqlstate value and in the handle to call my custom procedure having sqlstate as parameter, but I couldn't.
I sqw that I can handle the errors one by one (FK violation errors, unique violations errors, each of them having a sql state). But I was wondering if it is not possible to catch the sql state value and to have a single handle for sql state and in this handle to get sql state as parameter.