Operation Details
Description: Counts the number of active prior appeal cases the appealed case is already on.
Sterotype: ns
SQL
SELECT
  COUNT(*)
INTO
  :recordCount 
FROM
  AppealRelationship,
  CaseHeader 
WHERE AppealRelationship.priorAppealCaseID = :priorAppealCaseID 
  AND AppealRelationship.appealCaseID = CaseHeader.caseID 
  AND AppealRelationship.recordStatus = :normalRecordStatus 
  AND 
  (
    CaseHeader.statusCode = :activeStatusCode 
    OR CaseHeader.statusCode = :openStatusCode 
    OR CaseHeader.statusCode = :approvedStatusCode 
  )