不想在下面提到的oracle查询中使用@dtAttendance dt中的表变量

eanckbw9  于 2023-11-17  发布在  Oracle
关注(0)|答案(1)|浏览(102)

(how在Oracle中编写下面的代码)
在下面提到的oracle查询中,不想使用@dtAttendance dt中的表变量,不知道如何使用

PROCEDURE uploadShiftRoaster 
            (
            V_ShiftName varchar2  ,
            V_UpdatedBy Date DEFAULT null  ,
            
            V_TowerPk varchar2
            
           
            )
            as
            begin
                UPDATE A
                    SET A.ShiftName = dt.ShiftName, 
   A.ShiftStartTime=DATEDIFF * INTERVAL '1' dayA. AttendanceDate -'1900-01-01' +
               TO_CHAR(S.ShiftStartTime (8)),
                    A.ShiftEndTime=DATEDIFF * INTERVAL '1' day.AttendanceDate 
                case when dt.ShiftName='NIGHT' then -1 else 0 end +TO_CHAR(S.ShiftEndTime (8)),
                
                    A.ModifiedBy = V_UpdatedBy,
                    A.ModifiedOn = systimestamp
                    from T_ATTENDANCE_ATTENDANCE A join @dtAttendance dt on A.LoginId = dt.LoginID and A.AttendanceDate = dt.AttendanceDate 
                    left join T_ATTENDANCE_SHIFT_MASTER S on S.Shift=dt.ShiftName 
                    where a.AttendanceDate between systimestamp-1 and interval '+30' day + systimestamp
                    and A.LoginId in (Select LoginId from T_ATTENDANCE_USER_ATTENDANCE_TEAM where TowerPk = V_TowerPk and isActive = 'Y')
            end uploadShiftRoaster;

字符串

lp0sw83n

lp0sw83n1#

传入集合:

CREATE PROCEDURE exampleProcedure (
  v_dates SYS.ODCIDATELIST
)
AS
BEGIN
  UPDATE table_name
  SET    updated = 1
  WHERE  date_column IN (SELECT COLUMN_VALUE FROM TABLE(v_dates));
END exampleProcedure;
/

字符串
其中,对于样本数据:

CREATE TABLE table_name (date_column, updated) AS
SELECT DATE '1970-01-01' + LEVEL - 1, 0 FROM DUAL CONNECT BY LEVEL <= 5;


然后,如果调用该过程:

BEGIN
  exampleProcedure(
    SYS.ODCIDATELIST(DATE '1970-01-01', DATE '1970-01-04', DATE '1970-01-05')
  );
END;
/


然后,表格将更新为:
| 日期_列|更新|
| --|--|
| 1970-01-01 00:00:00| 1 |
| 2019 -01- 22 00:00:00| 0 |
| 2019 -01-03 00:00:00| 0 |
| 2019 -01-04 00:00:00| 1 |
| 2019 -01-05 00:00:00| 1 |
fiddle

相关问题