SELECT
ou.organisationUnitID,
ou.name,
ou.statusCode,
ou.creationDate,
ouparentlink.organisationStructureID
INTO
:orgUnitID,
:orgUnitName,
:orgUnitStatusCode,
:orgUnitCreationDate,
:orgStructureID
FROM
OrganisationUnit ou,
OrgUnitParentLink ouparentlink,
OrganisationStructure os
WHERE ou.organisationUnitID = ouparentlink.organisationUnitID
AND ouparentlink.organisationStructureID = os.organisationStructureID
AND ouparentlink.recordStatus <> :status
AND ou.organisationUnitID IN
(
SELECT
organisationUnitID
FROM
OrgUnitPositionLink opl1,
PositionHolderLink phl1,
Position p1,
OrganisationStructure os
WHERE p1.positionID = phl1.positionID
AND p1.leadPositionInd = '1'
AND phl1.positionID = opl1.positionID
AND os.organisationStructureID = opl1.organisationStructureID
AND os.organisationStructureID = phl1.organisationStructureID
AND phl1.userName = :userName
AND opl1.recordStatus <> :status
AND phl1.recordStatus <> :status
AND os.statusCode = :orgStructStatusCode
)
AND ou.recordStatus <> :status
AND os.statusCode = :orgStructStatusCode
ORDER BY ou.name
|