The RAISE_ERROR function can be used to signal application program and data problems. One situation where RAISE_ERROR may prove useful is in a CASE statement.
How to use RAISE_ERROR function in DB2 SQL. Understand and follow these secrets.
SELECT EMPNO,
CASE WHEN SEX = ‘M’ THEN ‘MALE ‘
WHEN SEX = ‘F’ THEN ‘FEMALE’
ELSE RAISE_ERROR(’70SX1′, ‘INVALID DATA, SEX IS NEITHER F NOR M.’)
END
FROM DSN71010.EMP;
There are three arguments in RAISE_ERROR function:
- Error to send
- Condition
- Requirement
Related articles
- MongoDB 2.4 is Out! (css.dzone.com)
- String Case statement vs If conditions (daniweb.com)