Good afternoon all. I've read the posted threads on this topic but none match my case and I'd really appreciate your help.
I use coalesce in my search query which, until now, worked great because none of the columns in the search criteria were nullable. My new search criterion (sup_tso_id) is nullable.
If the input parameter contains a value for sup_tso_id, then I want only rows where the sup_tso_id = @sup_tso_id else I want all rows regardless of the value of sup_tso_id which is nullbale (in conjuction with any other search criteria values that are passed as input parameters to the stored procedure).
I can handle this with nested ifs but this query was a maintenance nightmare using nested ifs until I cleaned it up by using coalesce and I'd like to keep it as clean as possible.
A portion of the search stored procedure:
Select *
From header_data
Where tx_id = coalesce(@tx_id,tx_id)
and tx_status = coalesce(@tx_status,tx_status)
and qa_tso_id = coalesce(@qa_tso_id,qa_tso_id)
and eval_id = coalesce(@eval_id,eval_id)
and sup_tso_id = ????????????
order by tx_id.
Thanks for any and all suggestions.

I use coalesce in my search query which, until now, worked great because none of the columns in the search criteria were nullable. My new search criterion (sup_tso_id) is nullable.
If the input parameter contains a value for sup_tso_id, then I want only rows where the sup_tso_id = @sup_tso_id else I want all rows regardless of the value of sup_tso_id which is nullbale (in conjuction with any other search criteria values that are passed as input parameters to the stored procedure).
I can handle this with nested ifs but this query was a maintenance nightmare using nested ifs until I cleaned it up by using coalesce and I'd like to keep it as clean as possible.
A portion of the search stored procedure:
Select *
From header_data
Where tx_id = coalesce(@tx_id,tx_id)
and tx_status = coalesce(@tx_status,tx_status)
and qa_tso_id = coalesce(@qa_tso_id,qa_tso_id)
and eval_id = coalesce(@eval_id,eval_id)
and sup_tso_id = ????????????
order by tx_id.
Thanks for any and all suggestions.