-- #New:29.06.2020/S.Gueth, get checkout information for objects
-- hint: for datasets do NOT use DatasetPUID as parameter --> use rrev_chain_anchoru from Table PDATASET

SELECT
  res.pdate      as CheckOutDate,    -- Checkout Date
  us.puser_id    as CheckOutUser,    -- CheckOut User
  res.pchange_id as CheckOutChangeId -- CheckOut ChangeID
FROM
  infodba.PIMANRELATION rel
  join infodba.PIMANTYPE typ on (typ.puid = rel.rrelation_typeu and typ.ptype_name = 'IMAN_RES_checkout')
  join infodba.PIMANRESERVATION res on rel.rsecondary_objectu = res.puid
  join infodba.PPOM_USER us on us.puid = res.ruser_objectu
WHERE
  rel.rprimary_objectu = :para_puid
