#1 2021-03-25 19:25:37

telpochyaotl
Member
Registered: 2021-02-17

Apply parameter to query only if parameter value is provided

Hello all!

Is there something way to add a parameter to a query only if the parameter value is provided? Something like $X{LESS, column, parameterkey} that can create a true condition (0=0) but that would do an IN or same thing that EQUALS do....

Given my use case I can use $P!{} but I thought I'd ask if there is some safer way to add a part of the WHERE clause conditionally based on the presence or not of a parameter value.

Maybe ${} can be used to check if a parameter is present and then issue $X{EQUAL...} or $X{IN....}, ? i don't know if that works, i'll need to play with it....

Offline

#2 2021-03-27 13:51:09

telpochyaotl
Member
Registered: 2021-02-17

Re: Apply parameter to query only if parameter value is provided

Ok, it can definitely be done using supported EL (thank you Reports Server!) one can add clauses to the WHERE conditionally using something like:

WHERE true $!{(empty selectRecords) ? '' : "AND id IN (".concat(selectRecords).concat(")")}

Offline

Board footer

Powered by FluxBB