SELECT
activityID,
userName,
organisationID,
subject,
activityTypeCode,
startDateTime,
endDateTime,
allDayInd,
locationID,
locationName,
priorityCode,
timeStatusCode,
notes,
recurrenceID,
caseID,
concernRoleID
INTO
:activityID,
:userName,
:organisationID,
:subject,
:activityTypeCode,
:startDateTime,
:endDateTime,
:allDayInd,
:locationID,
:locationName,
:priorityCode,
:timeStatusCode,
:notes,
:recurrenceID,
:caseID,
:concernRoleID
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
OR :activityIDIsNull <> '0'
)
AND
(
recurrenceID IS NULL
OR recurrenceID <> :recurrenceID
OR :recurrenceIDIsNull <> '0'
)
AND
(
startDateTime < :endDateTime
AND endDateTime > :startDateTime
)
AND
(
timeStatusCode = :busyStatusCode
OR timeStatusCode = :outStatusCode
)
AND recordStatusCode = :recordStatusCode
|