CREATE OR REPLACE PACKAGE BODY PKG_ATTENDANCE_DASHBOARD
AS
PROCEDURE Proc_Dashboard(
V_CommandType VARCHAR2,
V_LoginId VARCHAR2,
V_SignType VARCHAR2,
V_AttendanceDate DATE,
V_Year VARCHAR2,
V_Month VARCHAR2,
V_IPAddress VARCHAR2,
V_LogonUserName VARCHAR2,
V_WorkLocation VARCHAR2,
V_WorkLocationType VARCHAR2,
V_Company VARCHAR2,
V_UserType VARCHAR2,
V_ShiftName VARCHAR2,
V_Self_Covid_Status VARCHAR2,
V_Self_Covid_Remark VARCHAR2,
V_Family_Covid_Status VARCHAR2,
V_Family_Covid_Remark VARCHAR2,
V_UpdatedBy VARCHAR2
/* curGetCalendar OUT SYS_REFCURSOR,
curGetCovidStatus OUT SYS_REFCURSOR,
curListCompanyName OUT SYS_REFCURSOR,
curListTowerName OUT SYS_REFCURSOR,
curAttendanceListByDate OUT SYS_REFCURSOR*/
)
AS
V_Date DATE := TO_DATE (V_Year || '-' || V_Month || '-01', 'yyyy-mm-dd');
BEGIN
IF V_CommandType = 'getCalendar' THEN
WITH DaysInMonth (dates) AS
(SELECT V_Date AS dates FROM DUAL
UNION ALL
SELECT INTERVAL '1' DAY (5) + dates
FROM DaysInMonth
WHERE EXTRACT (MONTH FROM dates) = EXTRACT (MONTH FROM V_Date)
)
SELECT dates FROM DaysInMonth;
INSERT
INTO T_ATTENDANCE_ATTENDANCE
(
LoginId,
AttendanceDate,
ShiftName,
ShiftStartTime,
ShiftEndTime,
Active,
AttendanceStatus
)
SELECT u.LoginID,
d.dates,
'' ,
NULL,
NULL,
1,
'Approved'
FROM DaysInMonth d
CROSS JOIN T_ATTENDANCE_USER_MASTER u
WHERE extract(MONTH FROM dates) = extract(MONTH FROM V_Date)
AND LoginId = V_LoginId
AND NOT EXISTS
(SELECT LoginId
FROM T_ATTENDANCE_ATTENDANCE
WHERE LoginId = V_LoginId
AND EXTRACT(YEAR FROM ATTENDANCEDATE ) = extract(YEAR FROM V_Date)
AND EXTRACT(MONTH FROM AttendanceDate) = extract(MONTH FROM V_Date)
AND ACTIVE = 1
);
V_Date := INTERVAL '1' MONTH + V_Date;
WITH DaysInMonth (dates) AS
(SELECT V_Date AS dates FROM dual
UNION ALL
SELECT INTERVAL '1' DAY(5) + dates
FROM DaysInMonth
WHERE EXTRACT(MONTH FROM dates) = extract(MONTH FROM V_Date)
)
SELECT dates FROM DaysInMonth;
INSERT INTO T_ATTENDANCE_ATTENDANCE
(
LoginId,
AttendanceDate,
ShiftName,
ShiftStartTime,
ShiftEndTime,
Active,
AttendanceStatus
)
SELECT u.LoginID,
d.dates,
'',
NULL,
NULL,
1,
'Approved'
FROM DaysInMonth d
CROSS JOIN T_ATTENDANCE_USER_MASTER u
WHERE extract(MONTH FROM dates) = extract(MONTH FROM V_Date)
AND LoginId = V_LoginId
AND NOT EXISTS
(SELECT LoginId
FROM T_ATTENDANCE_ATTENDANCE
WHERE LoginId = V_LoginId
AND EXTRACT(YEAR FROM ATTENDANCEDATE ) = extract(YEAR FROM V_date)
AND EXTRACT(MONTH FROM AttendanceDate) = extract(MONTH FROM V_date)
AND ACTIVE = 1
);
OPEN curGetCalendar FOR SELECT AttendanceDate,
ShiftName,
TO_CHAR(AttendanceDate,'ddd') DAY,
V_Year,
V_Month ,
TO_CHAR(SignIn, 'yyyy-MM-dd hh:mm:ss tt') SignIn,
TO_CHAR(SignOut, 'yyyy-MM-dd hh:mm:ss tt') SignOut FROM T_ATTENDANCE_ATTENDANCE WHERE LoginId = V_LoginId AND EXTRACT(YEAR FROM ATTENDANCEDATE) = V_Year AND EXTRACT(MONTH FROM AttendanceDate) = V_Month AND ACTIVE = 1 order by AttendanceDate ASC;
--I am getting error here in below code
Update A
set A.ShiftName = case when to_char(TO_DATE(a.Attendancedate) ,'DAY') in ('SATURDAY') and week in (2,4) then 'WEEKLYOFF'
when to_Char(TO_DATE(a.Attendancedate),'WW') in ('SUNDAY') then 'WEEKLYOFF'
else 'GENERAL1' end
From
(
select attendancedate,shiftname, ROW_NUMBER() over (partition by to_char(TO_DATE(attendancedate,'DAY') order by attendancedate) as week from T_ATTENDANCE_ATTENDANCE A1
left join T_ATTENDANCE_USER_MASTER U on U.LoginId = A1.LoginId
left join T_ATTENDANCE_EMPLOYEE_MASTER E on E.EmpID = U.EmpID
where A1.loginid = V_LoginId and E.Company = '' and extract(year from attendancedate) = extract(year from Sysdate) and extract(month from attendancedate) = extract(month from
Sysdate()) and nvl(shiftname,'') = ''
) A
END IF
END Proc_Dashboard;
END PKG_ATTENDANCE_DASHBOARD;
字符串
1条答案
按热度按时间pbwdgjma1#
您(最初)过帐的代码仅部分是Oracle。修复后:
字符串
我不知道它是否会工作或不(我没有你的表也没有数据),但-至少-它应该 * 编译 *。
类似地,对于整个过程:你应该用分号终止语句;在那个
update
中使用一个 proper 子查询:型