-- TCUA IrAttr SYNC Data  L.Up 15.08.14
SELECT ir.pitem_revision_id AS IrRev,
  i.pitem_id                AS ItemName,
  i.puid                    AS ItemPuid,
  paoIr.plast_mod_date      AS IrLastModDate,
  paoIr.pcreation_date      AS IrCreateDate,
  s.psite_id                AS OwningSite_TC_pSite_ID
FROM infodba.PITEMREVISION ir
 LEFT JOIN infodba.PITEM i on (i.puid = ir.ritems_tagu)
 LEFT JOIN infodba.PPOM_OBJECT o on (ir.puid = o.puid)
 LEFT JOIN infodba.PPOM_IMC s on (o.rowning_siteu = s.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 ir.puid = :ir_puid
