Database SQL Operation: TaskAssignment.countTaskAssignmentForUserOrgUnitByTaskID
Description: | Returns the number of assignments to an organization unit by username either directly or indirectly. |
Sterotype: | ns |
SELECT
COUNT(*)
INTO
:numberOfRecords
FROM
TaskAssignment ta
WHERE ta.assigneeType = :assigneeType
AND ta.taskID = :taskID
AND ta.relatedID IN
(
SELECT
DISTINCT ou.organisationUnitID
FROM
Users u ,
PositionHolderLink ph ,
Position p ,
OrgUnitPositionLink oup ,
OrganisationUnit ou
WHERE u.userName = :userName
AND u.userName = ph.userName
AND ph.positionID = p.positionID
AND p.positionID = oup.positionID
AND oup.organisationUnitID = ou.organisationUnitID
AND ph.recordStatus = :recordStatus
AND :currentDate >= ph.fromDate
AND
(
:currentDate <= ph.toDate
OR ph.toDate IS NULL
)
)
|