Lab 6.3 NULLIF and COALESCE Functions

Lab Objectives

After this Lab, you will be able to:

Use the NULLIF Function

Use the COALESCE Function

The NULLIF and COALESCE functions are defined by the ANSI 1999 standard to be “CASE abbreviations.” Both functions can be used as a variety of the CASE expression.

NULLIF Function

The NULLIF function compares two expressions. If they are equal, then the function returns NULL; otherwise, it returns the value of the first expression. The NULLIF has the following structure:

NULLIF (expression1, expression2) 

If expression1 is equal to expression2, then NULLIF returns NULL. If expression1 does not equal expression2, NULLIF returns expression1. Note that the NULLIF function does the opposite of the NVL ...

Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.