-- #New: 29.05.2018/J.Fes
-- List for PFMaster:IrPuid all PFMembers
SELECT
 iMa.pitem_id AS PFMaster_ItemId,
 irMa.pitem_revision_id AS PFMaster_IrId,
 iMa.puid AS  PFMaster_ItemPuid,
 irMa.puid AS PFMaster_IrPuid,
 iMe.pitem_id AS PFMember_ItemId,
 irMe.pitem_revision_id AS PFMember_IrId,
 iMe.puid AS PFMember_ItemPuid,
 irMe.puid AS PFMember_IrPuid
FROM
 infodba.PITEMREVISION irMa
 LEFT JOIN infodba.PITEM iMa ON (iMa.puid = irMa.ritems_tagu)
 LEFT JOIN infodba.PIMANRELATION prMa ON (prMa.rsecondary_objectu = irMa.puid)
 LEFT JOIN infodba.PIMANTYPE ptypeMa ON (ptypeMa.puid = prMa.rrelation_typeu)
 LEFT JOIN infodba.PITEMREVISION irMe ON (irMe.puid = prMa.rprimary_objectu)
 LEFT JOIN infodba.PITEM iMe ON (iMe.puid = irMe.ritems_tagu)
 LEFT JOIN infodba.PWORKSPACEOBJECT pwoMe  ON (pwoMe.puid = irMe.puid)
WHERE
 ptypeMa.ptype_name = 'IMAN_UG_part_family_link'
 AND pwoMe.pactive_seq = 1
 AND irMa.puid = :ir_puid
Order by
 PFMember_ItemId,
 PFMember_IrId



