1

我有一个程序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_Condition1p_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) ); 

但是它不起作用。

感谢您的时间和考虑。

4

1 回答 1

1

我怀疑这些条件是你的问题:

p_Condition1 = null

没有任何东西等于 NULL。NULL 甚至不等于 NULL。相反,使用:

p_Condition1 IS NULL
于 2013-01-09T00:00:22.750 回答