The RAISE_ERROR function causes the statement that invokes the function to return an error with the specified SQLSTATE (along with SQLCODE -438) and error condition. The RAISE_ERROR function always returns NULL with an undefined data type.
If the SQLSTATE does not conform to these rules, an error is returned.
If an SQLCA is used,
Since the data type of the result of RAISE_ERROR is undefined, it may only be used where parameter markers are allowed. To use this function in a context where parameter markers are not allowed (such as alone in a select list), you must use a cast specification to give a data type to the null value that is returned. The RAISE_ERROR function cannot be used with CASE expressions.
CREATE TRIGGER EMPISRT1 AFTER INSERT ON EMPLOYEE REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL BEGIN ATOMIC IF N.BONUS > 20000 THEN VALUES( RAISE_ERROR( 'ZZZZZ', 'Incorrect bonus' ) ); END IF; END
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.