NattyLight, there are a few ways this might be done.
One is to build the query string with if statements used to add the other Where clauses as needed. Then run it dynamically.
Another is to do something like this:
Code:
SELECT columns
FROM table-name
WHERE Key_Col1 = variable
AND Key_Col2 = variable
AND Key_Col3 = variable
AND Opt_Char_Col1 LIKE variableC || '%'
AND Opt_Numeric_Col1 BETWEEN COALESCE(variableN,0) AND COALESCE(VariableN,max-value)
This assumes the Character variableC is an empty string ( '' ) is you don't want to filter on it or a value if you do.
Also, the Numeric VariableN is a NULL if you don't want to filter on it or an actual value if you do.
I might come up with a third way if neither of these work.