SELECT
Activity.activityID,
Activity.userName,
Activity.organisationID,
Activity.subject,
Activity.activityTypeCode,
Activity.startDateTime,
Activity.endDateTime,
Activity.allDayInd,
Activity.locationID,
Activity.locationName,
Activity.priorityCode,
Activity.timeStatusCode,
Activity.notes,
Activity.recurrenceID,
Activity.caseID,
Activity.concernRoleID,
Activity.slotAllocationID
INTO
:activityID,
:userName,
:organisationID,
:subject,
:activityTypeCode,
:startDateTime,
:endDateTime,
:allDayInd,
:locationID,
:locationName,
:priorityCode,
:timeStatusCode,
:notes,
:recurrenceID,
:caseID,
:concernRoleID,
:slotAllocationID
FROM
Activity
WHERE
(
(
userName = :userName
OR organisationID = :organisationID
)
OR
(
activityID IN
(
SELECT
activityID
FROM
ActivityAttendee
WHERE userName = :userName
AND recordStatusCode = :recordStatusCode
)
)
)
AND startDateTime <= :endDateTime
AND endDateTime >= :startDateTime
AND recordStatusCode = :recordStatusCode
ORDER BY startDateTime
|