-- PartFamiliy returns if Ir isMasterOrMember or NO PF #New: 06.11.17
-- #LUp: 10.05.2018/J.Fes returns now also PFMasterPuid PFMemberPuid
-- #LUP: 29.05.2018/J.Fes renamed PFMasterPuid -> PFMasterIrPuid  PFMemberPuid -> PFMemberIrPuid
SELECT
 /*MsSQL TOP (1) MsSQL*/
 i.pitem_id AS ItemId,
 ir.pitem_revision_id AS IrId,
 CASE WHEN (prMa.rsecondary_objectu = ir.puid) THEN 1 ELSE 0 END AS IsPFMaster,
 CASE WHEN (prMa.rsecondary_objectu = ir.puid) THEN ir.puid ELSE prMa.rsecondary_objectu END PFMaster_IrPuid,
 CASE WHEN (prMa.rprimary_objectu = ir.puid) THEN 1 ELSE 0 END IsPFMember,
 CASE WHEN (prMa.rprimary_objectu = ir.puid) THEN ir.puid ELSE prMa.rprimary_objectu END PFMember_IrPuid
FROM
 infodba.PITEMREVISION ir
 INNER JOIN infodba.PITEM i ON (i.puid = ir.ritems_tagu)
 LEFT JOIN infodba.PIMANRELATION prMa ON (prMa.rprimary_objectu = ir.puid or prMa.rsecondary_objectu = ir.puid)
 LEFT JOIN infodba.PIMANTYPE ptypeMa ON (ptypeMa.puid = prMa.rrelation_typeu)
WHERE
 ptypeMa.ptype_name = 'IMAN_UG_part_family_link'
 AND ir.puid = :ir_puid
/*Ora AND ROWNUM <= 1 Ora*/
