This question is almost exactly like mine but none of the answers work with my case.
If it was my question I'd slightly edit it to make it a different question. This question is thus different from the linked one.
Here's the problem: I want a way to match any non-null value ('%'
) AND null values.
The thing is:
I'm using oracle so I can't use
IsNull
Some columns are
NUMBER
s, which means I can't useCOALESCE(column, ' ')
. (ORA-00932: inconsistent datatypes: expected NUMBER got CHAR). However,like '%'
andlike '2118'
do work on NUMBER columns.
None of the answers apply to this problem because you can't make a null into an empty string when the column is a NUMBER.
How could I do to achieve this?
Some context:
My procedure takes a lot of parameters, and does a select with all of them. They can all have a value or be null, so if they're null they're replaced with '%'
.
That way, the procedure does :
where t.col1 like param1
and t.col2 like param2
...
Most of the times, only one or two parameters is not null. For the others parameters, the procedure needs to match on every row.
But when the value is null, like '%'
doesn't match the row. I'm looking for a way to match anything when param x is empty (so paramx = '%'
)