I have a query where not all conditions are necessary. Here\'s an example of what it looks like when all conditions are used:
select num
from (select distinct q.
I would just do this
select num
from (select distinct q.num
from cqqv q
where q.bcode = '1234567' --this is variable
and q.lb = 'AXCT' --this is variable
and q.type = nvl(, q.type) --this condition ignored because of "type=*" in input
and q.edate > sysdate - 30 --this is variable
order by dbms_random.value()) subq
where rownum <= 10; --this is variable
One only has to guarantee that the variable-type is null when the q.TYPE filtering is to be ignored.