We use parameter replacement to build dynamic queries.
We have a table that stores customer returns, each return has a return reason bucket (RTN_BUCKET) and a return reason code (RTN_RSN_CODE). We have a UI that filters the data on some fields. Fields in the filter are optional. We are able to solve this for simple field comparison, however we are not able to figure out how to achieve this for tuple matches like (RTN_BUCKET, RTN_RSN_CODE).
Here is a sample query -
select * From returns
where RTN_DT > :someDateParam
and (isNull(:upc) OR UPC = :upc) -- works for UPC if we replace the value with null
and (isNull(:reasonFilter) OR (RTN_BUCKET, RTN_REASON_CODE) in (:reasonFilter))
We were planning on passing reason filter as -
reasonFilter: "('damaged','package damaged'), ('damaged', 'item damaged'))
Please let me know if there is any other innovative way to solve this.
Thanks,
Amit