我有一个程序EMPHIRESEPCHAN
,用于获取雇佣,分离并根据特定时间框架更改其职位的员工名单。程序如下:
PROCEDURE EMPHIRESEPCHAN ( p_Start in VarChar2, p_End in VarChar2,
p_Hire IN VarChar2, p_Sep IN VarChar2, p_Changed IN VarChar2, p_Condition1 IN VarChar2, p_Condition2 IN VarChar2)
IS
CURSOR c_emplst ( p_listtype varchar2 ) IS
select e.emp_id, e.name, e.Rank
from person.emp e
where emp_id in (select distinct(emp_id) from person.promo
where pdate between p_startDate and p_endDate
and dcode in
(select adj from support.descr where typ = 'PROMO' and smeaning = p_listtype) );
CURSOR c_promolst ( p_emp_id varchar2 ) IS
select pdate
from person.promo
where emp_id = p_emp_id
order by 2 desc;
Begin
for EmpRec in c_emplst ('HIRE')
LOOP
for PromoRec in c_PromoLst ( EmpRec.emp )
LOOP
if PromoRec.Dcode in ('TEMPORARY','RETURN','APPOINTED' )
-- Do all the operation
end if;
end loop;
end loop;
end EMPHIRESEPCHAN;
我必须修改程序以根据p_Condition1
和p_Condition2
参数检索员工列表。
如果是p_Condition1 is not null and p_Condition2 is null
,我必须检索拥有Rank = 'Developer'
如果p_Condition1 is null and p_Condition2 is not null
我必须检索拥有Rank = 'Tester'
如果p_Condition1 and p_Condition2 is not null
我必须检索排名为'开发人员'和'测试人员'的员工。
我在各个网站上阅读了很多帖子,找到了我无法遵循的答案。
根据帖子,我对光标进行了如下修改
CURSOR c_emplst ( p_listtype varchar2 ) IS
select e.emp_id, e.name, e.Rank
from person.emp e
where ( p_Condition1 = null and p_Condition2 = null = and emp_id in (select distinct(emp_id) from person.promo
where pdate between p_startDate and p_endDate
and dcode in (select adj from support.descr where typ = 'PROMO' and smeaning = p_listtype) )
or ( p_Condition1 > null and p_Condition2 = null = and emp_id in (select distinct(emp_id) from person.promo
where pdate between p_startDate and p_endDate
and Rank ='Developer'
and dcode in (select adj from support.descr where typ = 'PROMO' and smeaning = p_listtype) )
or ( p_Condition1 = null and p_Condition2 > null = and emp_id in (select distinct(emp_id) from person.promo
where pdate between p_startDate and p_endDate
and Rank = 'Tester'
and dcode in (select adj from support.descr where typ = 'PROMO' and smeaning = p_listtype) );
然而它无效。
感谢您的时间和考虑。
答案 0 :(得分:1)
我怀疑这些条件是你的问题:
p_Condition1 = null
没有任何东西等于NULL。 NULL甚至不等于NULL。相反,使用:
p_Condition1 IS NULL