/* TCUA:IRs 18.07.14 returns IR Latest of ITEM */
SELECT * 
from (
SELECT 
  i.pitem_id           AS I_Id,
  ir.pitem_revision_id AS Ir_Id,
  i.puid               AS I_puid,
  ir.puid              AS Ir_puid,
  paoIr.plast_mod_date AS Ir_LastModDate,
  paoIr.pcreation_date AS Ir_CreationDate,
  RANK() OVER (ORDER BY paoIr.pcreation_date DESC) AS rank
FROM infodba.PITEM i
 LEFT JOIN infodba.PITEMREVISION ir on (i.puid = ir.ritems_tagu)
 LEFT JOIN infodba.PPOM_OBJECT o on (ir.puid = o.puid)
 LEFT JOIN infodba.PPOM_APPLICATION_OBJECT paoIr ON (ir.puid = paoIr.puid)
 LEFT JOIN infodba.PWORKSPACEOBJECT pwo On (ir.puid = pwo.puid)
Where
 pwo.pactive_seq = 1
 AND i.pitem_id = 'BG-Einzelteil-01'
-- AND i.puid = :para_Ipuid -- irBOML ''irBOML' -- 'wfF5F$mhTzDfjB'
--  AND i.pitem_id = :para_I_ID -- 'BG-Einzelteil-01' 'Item'
)  where rank = 1
;



