Operation Details
Description:  
Sterotype: ns
SQL
SELECT
  DISTINCT(percentage)
INTO
  :percentage 
FROM
  InvestigationApprovalCheck,
  PositionHolderLink,
  Position,
  OrganisationUnit,
  OrgUnitPositionLink 
WHERE percentage = 
  ( 
  SELECT
    MAX(percentage) 
  FROM
    InvestigationApprovalCheck,
    PositionHolderLink,
    Position,
    OrganisationUnit,
    OrgUnitPositionLink 
  WHERE PositionHolderLink.userName = :userName 
    AND Position.positionID = PositionHolderLink.positionID 
    AND 
    (
      
      (
        OrgUnitPositionLink.organisationUnitID = OrganisationUnit.organisationUnitID 
      ) 
      AND 
      (
        OrgUnitPositionLink.positionID = Position.positionID 
      ) 
    ) 
    AND InvestigationApprovalCheck.typeCode = :typeCode 
    AND InvestigationApprovalCheck.recordStatus = :recordStatus 
  ) 
  AND PositionHolderLink.userName = :userName 
  AND Position.positionID = PositionHolderLink.positionID 
  AND 
  (
    
    (
      OrgUnitPositionLink.organisationUnitID = OrganisationUnit.organisationUnitID 
    ) 
    AND 
    (
      OrgUnitPositionLink.positionID = Position.positionID 
    ) 
  ) 
  AND InvestigationApprovalCheck.typeCode = :typeCode 
  AND InvestigationApprovalCheck.recordStatus = :recordStatus