Skip to content
Advertisement

SQL: SAP Hana if parameter is null, ignore where

I’m passing 3 parameters into my Hana Stored Procedure to use as WHERE clauses, and if the parameter is null, I want the procedure to behave as though that condition doesn’t exist.

example:

if one of the input parameters is deviceType.

if deviceType is null, query should simply be

I know I can achieve this with if statements, but is there another way to do it?

Advertisement

Answer

When using SQLScript you can use the APPLY_FILTER() function.

E.g.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement