Operation Details
Description: Returns the number of task assignments for user jobs per taskID.
Sterotype: ns
SQL
SELECT
  COUNT(*)
INTO
  :numberOfRecords 
FROM
  TaskAssignment ta 
WHERE ta.assigneeType = :assigneeType 
  AND ta.taskID = :taskID 
  AND ta.relatedID IN 
  ( 
  SELECT
    DISTINCT j.jobID 
  FROM
    Users u,
    PositionHolderLink ph,
    Position p,
    OrgUnitPositionLink oup ,
    Job j 
  WHERE u.userName = :userName 
    AND u.userName = ph.userName 
    AND ph.positionID = p.positionID 
    AND p.positionID = oup.positionID 
    AND j.jobID =p.jobID 
    AND ph.recordStatus = :recordStatus 
    AND :currentDate >= ph.fromDate 
    AND 
    (
      :currentDate <= ph.toDate 
      OR ph.toDate IS NULL 
    ) 
  )