select * from table1
where decode(nvl(变量1,''),1,name) = (case when nvl(变量1,'') = '' then 1 else 变量1 end)
and decode(nvl(变量2,''),1,sex) = (case when nvl(变量2,'') = '' then 1 else 变量2 end)
select * from table1
where decode(&变量1,'','0000',name) = (case when nvl(&变量1,'') is null then '0001' else &变量1 end)
or decode(&变量2,'','0000',sex) = (case when nvl(&变量2,'') is null then '0001' else &变量2 end)
or (decode(&变量1,'','0000',name) = (case when nvl(&变量1,'') is null then '0000' else &变量1 end)--当变量1,变量2都为空时,显示所有
and decode(&变量2,'','0000',sex) = (case when nvl(&变量2,'') is null then '0000' else &变量2 end))
where decode(nvl(变量1,''),1,name) = (case when nvl(变量1,'') = '' then 1 else 变量1 end)
and decode(nvl(变量2,''),1,sex) = (case when nvl(变量2,'') = '' then 1 else 变量2 end)
select * from table1
where decode(&变量1,'','0000',name) = (case when nvl(&变量1,'') is null then '0001' else &变量1 end)
or decode(&变量2,'','0000',sex) = (case when nvl(&变量2,'') is null then '0001' else &变量2 end)
or (decode(&变量1,'','0000',name) = (case when nvl(&变量1,'') is null then '0000' else &变量1 end)--当变量1,变量2都为空时,显示所有
and decode(&变量2,'','0000',sex) = (case when nvl(&变量2,'') is null then '0000' else &变量2 end))