Operation Details
Description: Searches for the maximum end date-time where the start and end date-times overlap with the start and end date times provided in the key for the specified user. The time status codes must match the time status codes provided.
Sterotype: ns
SQL
SELECT
  MAX(endDateTime)
INTO
  :overlapDateTime 
FROM
  Activity 
WHERE 
  (
    
    (
      userName = :userName 
      OR organisationID = :organisationID 
    ) 
    OR 
    (
      activityID IN 
      ( 
      SELECT
        activityID 
      FROM
        ActivityAttendee 
      WHERE userName = :userName 
        AND recordStatusCode = :recordStatusCode 
        AND acceptedInd = :acceptedInd 
      ) 
    ) 
  ) 
  AND activityID <> :activityID 
  AND startDateTime < :endDateTime 
  AND endDateTime > :startDateTime 
  AND 
  (
    timeStatusCode = :busyStatusCode 
    OR timeStatusCode = :outStatusCode 
  ) 
  AND recordStatusCode = :recordStatusCode