SELECT
AppealRelationship.appealRelationshipID,
AppealRelationship.priorAppealCaseID AS caseID,
caseReference,
Appeal.appealTypeCode AS appealedCaseType,
AppealRelationship.recordStatus,
AppealRelationship.statusCode,
AppealRelationship.receivedDate,
AppealRelationship.receiptNoticeIndicator
INTO
:appealRelationshipID,
:caseID,
:caseReference,
:appealedCaseType,
:recordStatus,
:statusCode,
:receivedDate,
:receiptNoticeIndicator
FROM
AppealRelationship,
CaseHeader,
Appeal
WHERE AppealRelationship.appealCaseID = :appealCaseID
AND AppealRelationship.CaseID = CaseHeader.caseID
AND AppealRelationship.priorAppealCaseID = Appeal.caseID
AND caseTypeCode <> :caseTypeCode
AND AppealRelationship.priorAppealCaseID IS NOT NULL
UNION ALL
(
SELECT
AppealRelationship.appealRelationshipID,
AppealRelationship.caseID AS caseID,
caseReference,
Appeal.appealTypeCode AS appealedCaseType,
AppealRelationship.recordStatus,
AppealRelationship.statusCode,
AppealRelationship.receivedDate,
AppealRelationship.receiptNoticeIndicator
FROM
AppealRelationship,
CaseHeader,
Appeal
WHERE AppealRelationship.appealCaseID = :appealCaseID
AND AppealRelationship.caseID = CaseHeader.caseID
AND AppealRelationship.caseID = Appeal.caseID
AND caseTypeCode <> :caseTypeCode
AND AppealRelationship.priorAppealCaseID IS NOT NULL
UNION
SELECT
AppealRelationship.appealRelationshipID,
AppealRelationship.caseID AS caseID,
caseReference,
caseTypeCode AS appealedCaseType,
AppealRelationship.recordStatus,
AppealRelationship.statusCode,
AppealRelationship.receivedDate,
AppealRelationship.receiptNoticeIndicator
FROM
AppealRelationship,
CaseHeader
WHERE AppealRelationship.appealCaseID = :appealCaseID
AND AppealRelationship.caseID = CaseHeader.caseID
AND caseTypeCode <> :caseTypeCode
AND AppealRelationship.priorAppealCaseID IS NULL
)
|