SELECT
t.taskID,
t.priority,
t.reservedBy,
e.fullName,
t.assignedDateTime,
w.deadlineTime,
t.wdoSnapshot,
t.overflowInd
INTO
:taskID,
:taskPriority,
:taskReservedByUserName,
:taskReservedByFullUserName,
:taskAssignedDateTime,
:taskDeadlineDateTime,
:wdoSnapshot,
:overflowInd
FROM
Task t
LEFT OUTER JOIN
ExternalUser e
ON (t.reservedBy = e.userName)
LEFT OUTER JOIN
WorkflowDeadline w
ON (t.taskID = w.taskID)
WHERE w.deadlineTime >= :fromDeadlineDateTime
AND w.deadlineTime < :toDeadlineDateTime
AND
(
t.taskID IN
(
SELECT
taskID
FROM
TaskUserAssignment tua
WHERE tua.userName = :userName
)
OR
(
t.taskID IN
(
SELECT
taskID
FROM
TaskWorkQueueAssignment tw
WHERE tw.workQueueID IN
(
SELECT
workQueueID
FROM
WorkQueueSubscription wq
WHERE wq.userName = :userName
)
)
)
)
AND
(
(
:allUserTasksInd = '0'
OR
(
t.reservedBy IS NULL
OR t.reservedBy IS NOT NULL
)
)
AND
(
:allReservedUserTasksInd = '0'
OR t.reservedBy IS NOT NULL
)
AND
(
:allAssignedUserTasksInd = '0'
OR t.reservedBy IS NULL
)
)
ORDER BY deadlineTime ASC
|