How can I select records from a table , say emp, when I have a parameter for where condition like
if empno is known then use in where clause,
if ename is known then use ename in where clause,
if both are known then use both parameters in where clause.
I am using Oracle 9i.
psuedo code.
...
if p_empno is not null and p_ename is not null then
select * from emp
where empno=p_emp and ename = p_ename ;
elsif p_empno is null and p_ename is not null then
select * from emp
where ename = p_ename ;
elsif p_empno is not null p_ename is null then
select * from emp
where empno=p_emp ;
else
select * from emp
end if ;
...
how can I do this in sql or plsql
thanks
Edited by: user10999538 on Jul 15, 2009 3:29 AM