SQLSERVER存儲過程轉換oracle

今天幫人把一個SQL SERVER的簡單存儲過程改成了ORACEL的存儲過程

 

--以前這個存儲過程是SQL Server的,我想把它用oracle語句來,但是編譯不過,有錯誤,請大家指教一下,

create or replace p_GetPrenDataOfAtt(yymmdd1 date,empid1 number)
as 
RHour11 float;
RHour21 float;
PreWTID varchar2(20);
PreLastOut number;

begin
  select PreLastOUT:=case 
  when IntGO5>-1 and IntOUT5>-1 then IntOUT5;
  when IntGO4>-1 and IntOUT4>-1 then IntOUT4;
  when IntGO3>-1 and IntOUT3>-1 then IntOUT3;
  when IntGO2>-1 and IntOUT2>-1 then IntOUT2;
  when IntGO1>-1 and IntOUT1>-1 then IntOUT1;
  end case,
  RHour11: = RHour1, RHour21: = RHour2 , PreWTID:= WTID
  from AttDayData where YYMMDD =YYMMDD1 - 1 and EmpID=EmpID1;
   
  if PreLastOUT is null then
  PreLastOUT: = -1;
  end if;
   
  if PreLastOUT >1440 then
  PreLastOUT: = PreLastOUT - 1440;
  else
  PreLastOUT:= 0 ;
  end if ;
   
  if RHour11>0 or RHour21>0 or PreWTID is null then
  select PreWTID:=a.WTID from
  (select row_number()over(order by YYMMDD DESC) as "row",wtid from AttDayData where YYMMDD < yymmdd1 -1 and EmpID =EmpID1;)a
  where a.row=1;
  end if;
   
   
end ;

 

--------------------------

 

create or replace procedure p_GetPrenDataOfAtt(yymmdd1 date,empid1 number)
as
RHour11 float;
RHour21 float;
PreWTID varchar2(20);
PreLastOut number;

begin
  select  case
  when IntGO5>-1 and IntOUT5>-1 then IntOUT5
  when IntGO4>-1 and IntOUT4>-1 then IntOUT4
  when IntGO3>-1 and IntOUT3>-1 then IntOUT3
  when IntGO2>-1 and IntOUT2>-1 then IntOUT2
  when IntGO1>-1 and IntOUT1>-1 then IntOUT1
  end case,
  --RHour11: = RHour1, RHour21: = RHour2 , PreWTID:= WTID
  RHour1,RHour2,WTID into PreLastOUT,RHour11,RHour21,PreWTID
  from AttDayData where YYMMDD =YYMMDD1 - 1 and EmpID=EmpID1;

  if PreLastOUT is null then
  PreLastOUT:= -1;
  end if;

  if PreLastOUT >1440 then
  PreLastOUT:= PreLastOUT - 1440;
  else
  PreLastOUT:= 0 ;
  end if ;

  if RHour11>0 or RHour21>0 or PreWTID is null then
 -- select PreWTID:=a.WTID from
 select  a.WTID into PreWTID from
  (select row_number()over(order by YYMMDD DESC) as "row",wtid from AttDayData where YYMMDD < yymmdd1 -1 and EmpID =EmpID1) a
  where rownum=1;
  end if;


end ;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章