SELECT
wq.name,
wq.workQueueID,
wqs.subscriberID,
p.name AS subscriberName,
wqs.subscriberType,
wqs.subscriptionDateTime
INTO
:workQueueName,
:workQueueID,
:subscriberID,
:subscriberName,
:subscriberType,
:subscriptionDateTime
FROM
WorkQueue wq,
WorkQueueSubscription wqs,
Position p
WHERE wq.workQueueID = wqs.workQueueID
AND wqs.subscriberType = :subscriberType
AND p.positionID = wqs.subscriberID
AND wqs.subscriberID IN
(
SELECT
DISTINCT p.positionID
FROM
Users u,
PositionHolderLink ph,
Position p
WHERE u.userName = :userName
AND u.userName = ph.userName
AND ph.positionID = p.positionID
AND ph.recordStatus = :recordStatus
AND
(
(
ph.fromDate <= :currentDate
AND ph.toDate IS NULL
)
OR
(
ph.fromDate <= :currentDate
AND ph.toDate >= :currentDate
)
)
)
ORDER BY wq.name
|