Performing Null check using HANA SQL Script

SAP HANASAPSAP Basis

You can go for using either NULLIF or COALESCE function to serve your requirement.

NULLIF (expression, expression"): This function will return the same type whatever is specified as the first expression.

Basically, NULLIF returns

  • The first expression if the two expressions are not equal.

  • NULL of type of first expressions if the expressions are equal

The other function available is COALESCE which basically checks if the first Value provided is NULL then it will return the second value.

Example

c = COALESCE(b , a)

If b is null then the function will return an otherwise b. So If you need to put a null check and use some default value in place of NULL then you can go ahead and use COALESCE.

raja
Published on 15-Dec-2017 13:16:44
Advertisements