Operation Details
Description: Reads Org Unit Product Approval Check for its percentage amount
Sterotype: ns
SQL
SELECT
  DISTINCT(percentage)
INTO
  :percentage 
FROM
  CaseApprovalCheck,
  PositionHolderLink,
  Position,
  OrganisationUnit,
  OrgUnitPositionLink 
WHERE percentage = 
  ( 
  SELECT
    MAX(percentage) 
  FROM
    CaseApprovalCheck,
    PositionHolderLink,
    Position,
    OrganisationUnit,
    OrgUnitPositionLink 
  WHERE PositionHolderLink.userName = :userName 
    AND Position.positionID = PositionHolderLink.positionID 
    AND 
    (
      
      (
        OrgUnitPositionLink.organisationUnitID = OrganisationUnit.organisationUnitID 
      ) 
      AND 
      (
        OrgUnitPositionLink.positionID = Position.positionID 
      ) 
    ) 
    AND CaseApprovalCheck.typeCode = :typeCode 
    AND CaseApprovalCheck.productID = :productID 
    AND CaseApprovalCheck.estimatedCost = :estimatedCost 
    AND CaseApprovalCheck.statusCode = :statusCode 
  ) 
  AND PositionHolderLink.userName = :userName 
  AND Position.positionID = PositionHolderLink.positionID 
  AND 
  (
    
    (
      OrgUnitPositionLink.organisationUnitID = OrganisationUnit.organisationUnitID 
    ) 
    AND 
    (
      OrgUnitPositionLink.positionID = Position.positionID 
    ) 
  ) 
  AND CaseApprovalCheck.typeCode = :typeCode 
  AND CaseApprovalCheck.productID = :productID 
  AND CaseApprovalCheck.estimatedCost = :estimatedCost 
  AND CaseApprovalCheck.statusCode = :statusCode