为oracle sql中的两个不同列添加条件where子句

为oracle sql中的两个不同列添加条件where子句,oracle,Oracle,我需要编写一个查询,其中需要根据客户机上两个不同位置的输入值附加where子句。例如,我只从一个页面获取id,从另一个页面获取筛选记录的日期范围 在这两种情况下,查询结果是相同的,所以我在考虑如何基于输入(Id或日期范围)编写where子句 例如-员工表: 如果从一个屏幕上我有id,从另一个日期范围,那么我想在oracle sql中构建一个动态查询来获取结果集- select * (required columns) from employee where -- other filter c

我需要编写一个查询,其中需要根据客户机上两个不同位置的输入值附加where子句。例如,我只从一个页面获取id,从另一个页面获取筛选记录的日期范围

在这两种情况下,查询结果是相同的,所以我在考虑如何基于输入(Id或日期范围)编写where子句

例如-员工表:

如果从一个屏幕上我有id,从另一个日期范围,那么我想在oracle sql中构建一个动态查询来获取结果集-

select * (required columns) from employee 
where 
-- other filter criteria     
and if {employee_id is received} then id = ${employee_id} 
else if {date range is received} then joining_date between {date range}
注意:JOIN中还有多个表,我在这里没有包括这些表。
任何帮助都将不胜感激。:)

看看这样做是否有帮助;这个例子基于Scott的sample
EMP
表(因为我没有您的表),所以-为了测试查询,我使用了我所拥有的

select deptno, empno, ename, job, hiredate
from emp
where (    empno = :par_empno
       or :par_empno is null
      )
  and (    hiredate between :par_date_from and :par_date_to
       or (:par_date_from is null and :par_date_to is null)
      );