/* TCUA get for ItemRev i.puid + ir.puid L.Up 15.08.14 J.Fes */
Select
  i.puid               AS ItemPuid,
  i.pitem_id           AS ItemId,
  ir.puid              AS IrPuid,
  ir.pitem_revision_id AS IrId
From
  infodba.PITEM i
  INNER JOIN infodba.PITEMREVISION ir On (ir.ritems_tagu = i.puid)
  LEFT JOIN infodba.PWORKSPACEOBJECT pwo On (ir.puid = pwo.puid)
WHERE
  pwo.pactive_seq = 1
  AND UPPER(i.pitem_id) = UPPER(:i_pitem_id)
  And UPPER(ir.pitem_revision_id) = UPPER(:ir_pitem_revision_id)
order by  ir.psequence_id desc
