Operation Details
Description: Returns count of records for the EvidenceFormID and status and endDate less than the provided one
Sterotype: ns
SQL
SELECT
  COUNT(*)
INTO
  :value 
FROM
  ProductEvidenceFormLink 
WHERE ProductEvidenceFormLink.evidenceFormID = :evidenceFormID 
  AND 
  (
    ProductEvidenceFormLink.endDate >= :currentDate 
    OR :currentDate IS NULL 
    OR ProductEvidenceFormLink.endDate IS NULL 
  ) 
  AND 
  (
    ProductEvidenceFormLink.recordStatus = :recordStatus 
    OR :recordStatus IS NULL 
  )