SELECT
OU.organisationUnitID,
OU.name,
OU.businessTypeCode,
OU.creationDate,
OU.recordStatus,
OU.webAddress,
OU.comments,
OU.defaultPrinterID,
OU.statusCode,
OrgUnitParentLink.parentOrganisationUnitID,
OUPARENT.name,
OrgUnitParentLink.organisationStructureID,
OU.versionNo,
OU.readSID,
OU.maintainSID,
OU.createUnitSID,
(
SELECT
Location.name
FROM
OrganisationUnit
LEFT OUTER JOIN
location
ON OrganisationUnit.locationID = location.locationID
WHERE OrganisationUnit.organisationUnitID = ou.organisationUnitID
) locationID
INTO
:organisationUnitID,
:name,
:businessTypeCode,
:creationDate,
:recordStatus,
:webAddress,
:comments,
:defaultPrinterID,
:statusCode,
:parentOrganisationUnitID,
:parentOrganisationUnitName,
:organisationStructureID,
:versionNo,
:readSID,
:maintainSID,
:createSID,
:locationName
FROM
OrganisationUnit OU,
OrgUnitParentLink
LEFT OUTER JOIN
OrganisationUnit OUPARENT
ON OrgUnitParentLink.parentOrganisationUnitID = OUPARENT.organisationUnitID
WHERE OrgUnitParentLink.organisationStructureID = :organisationStructureID
AND OrgUnitParentLink.organisationUnitID = :organisationUnitID
AND OrgUnitParentLink.organisationUnitID = OU.organisationUnitID
|