SELECT
CaseEvidenceTree.caseEvidenceTreeID,
CaseEvidenceTree.caseID,
CaseEvidenceTree.effectiveFrom,
CaseEvidenceTree.statusCode,
CaseEvidenceTree.previousEvidenceID,
CaseEvidenceTree.versionNo
INTO
:caseEvidenceTreeID,
:caseID,
:effectiveFrom,
:statusCode,
:previousEvidenceID,
:versionNo
FROM
CaseEvidenceTree
WHERE CaseEvidenceTree.caseID = :caseID
AND
(
(
CaseEvidenceTree.effectiveFrom = :effectiveFrom
AND :useDateInd <> '0'
)
OR
(
CaseEvidenceTree.effectiveFrom IS NULL
AND :useDateInd = '0'
)
)
ORDER BY caseID,
effectiveFrom,
statusCode
|