User-generated exceptions
You can generate your own error using the RAISE EXCEPTION
statement, as the following figure shows.
In the example, the ON EXCEPTION statement uses two variables, esql and eisam, to hold the error numbers that the database server returns. The IF clause executes if an error occurs and if the SQL error number is -206. If any other SQL error is caught, it is passed out of this BEGINEND block to the last BEGINEND block of the previous example.