如何比较pl / sql if语句中的负数

时间:2015-05-14 14:23:29

标签: plsql

这是完整的功能

 Function GetStatus_TecTrac( inquiry_id IN number )
RETURN VARCHAR2
  IS
 status VARCHAR2(12);
  deptId number;
 endDate date;
  BEGIN

 select DEPT_ID, END_DATE into deptId , endDate from (
 select DEPT_ID, END_DATE
  from TB_PROJECT_TRACKING_DURATION tp
  where tp.INQUIRY_ID = inquiry_id
 order by START_DATE desc
 )
 where rownum = 1;


if (deptId = -61 and endDate is not null) then
    status := 'closed';
else
   status := 'open';
end if;

RETURN status;

END;

它总是返回状态为"关闭"在每个inquiry_id上,无论deptId和endDate的值是多少。 帮我解决这个问题。

提前致谢。 法尔汉

1 个答案:

答案 0 :(得分:0)

适合我。你是怎么测试的?

SQL> declare
      deptid number := 44;
      enddate date := sysdate;
      status varchar2(10);
    begin
      if (deptId = -61 and endDate is not null) then
        status := 'closed';
      else
        status := 'open';
      end if;

      dbms_output.put_line(status);
    end;
    /
open

PL/SQL procedure successfully completed.