Skip to Content
0
Sep 13, 2023 at 12:00 PM

Fuzzy Search Using CDS & SAP HANA with empty parameters

92 Views Last edit Sep 13, 2023 at 12:00 PM 2 rev

Hello.

I need to write fuzzy search statement .
my requirement is not to take into account parameters which are empty.

let's say:

et_data = select distinct score( ) as score, partner, name_first, name_last
from ZVWCDSDEMO
where
(
contains( name_first, :iv_first_name, fuzzy( 0.5 ) ) and
contains( name_last, :iv_last_name, fuzzy( 0.5 ) )
)
ORDER BY score( ) desc;

if iv_first_name is empty I want the select to work like this:

et_data = select distinct score( ) as score, partner, name_first, name_last
from ZVWCDSDEMO
where
(

****contains( name_first, :iv_first_name, fuzzy( 0.5 ) ) and
contains( name_last, :iv_last_name, fuzzy( 0.5 ) )
)
ORDER BY score( ) desc;

there are lots of combinations ( I have more parameters than 2 ).

I want to avoid "IF"s.

Is it a way not to take the parameter into account when it's empty?

Thank You, Łukasz.