![]() |
|
Use the RAISE EXCEPTION statement to simulate the generation of an error.
Use the RAISE EXCEPTION statement to simulate an error or to generate an error with a custom message. An ON EXCEPTION statement can trap the generated error.
If you omit the ISAM_error_var parameter, the database server sets the ISAM error code to zero (0) when the exception is raised. If you want to use the error_text_var parameter but not specify a value for ISAM_error_var, you can specify zero (0) as the value of ISAM_error_var.
The statement can raise either system-generated exceptions or user-generated exceptions.
For example, the following statement raises the error number -208 and inserts the text a missing file into the variable of the system-generated error message:
The special error number -746 allows you to produce a customized message. For example, the following statement raises the error number -746 and returns the quoted text:
In the following example, a negative value for alpha raises exception -746 and provides a specific message describing the problem. The code should contain an ON EXCEPTION statement that traps for an exception of -746.
When the SPL routine executes and the IF condition is met, the database server returns the following error:
For more information about the scope and compatibility of exceptions, see ON EXCEPTION.