SELECT
t.taskID,
t.priority,
t.reservedBy,
t.assignedDateTime,
u.fullName,
t.wdoSnapshot,
t.overflowInd,
w.deadlineTime
INTO
:taskID,
:priority,
:reservedBy,
:assignedDateTime,
:reservedByFullName,
:wdoSnapshot,
:overflowInd,
:deadlineDateTime
FROM
Task t
LEFT OUTER JOIN
Users u
ON (t.reservedBy = u.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
TaskWorkQueueAssignment twqa
WHERE twqa.workQueueID = :workQueueID
)
)
AND
(
(
:allWorkQueueTasksInd = '0'
OR
(
t.reservedBy IS NULL
OR t.reservedBy IS NOT NULL
)
)
AND
(
:allReservedWorkQueueTasksInd = '0'
OR t.reservedBy IS NOT NULL
)
AND
(
:allAssignedWorkQueueTasksInd = '0'
OR t.reservedBy IS NULL
)
)
ORDER BY t.assignedDateTime ASC
|