678: -- If rotation plan, get applicable work schedule id
679: -- Find rotation containing work date
680: SELECT rts.tws_id
681: INTO p_work_id
682: FROM hxt_rotation_schedules rts
683: WHERE rts.rtp_id = p_rotation_id
684: AND rts.start_date = (SELECT MAX(start_date)
685: FROM hxt_rotation_schedules
686: WHERE rtp_id = p_rotation_id
681: INTO p_work_id
682: FROM hxt_rotation_schedules rts
683: WHERE rts.rtp_id = p_rotation_id
684: AND rts.start_date = (SELECT MAX(start_date)
685: FROM hxt_rotation_schedules
686: WHERE rtp_id = p_rotation_id
687: AND start_date <= p_date
688: );
689: --ORACLE END IF;