-- #New: 25.02.2026/J.Fes
-- #Doc: Get via DataSets_GetForItemIdAndRevIdFiterByTypeNameByObjectName.sql
Select
 i.pitem_id as Item_id,
 ir.PITEM_REVISION_ID as IR_id,
 pd.puid As DataSetPuid,
 ptype.ptype_name As DatasetRelation,
 pdt.pdatasettype_name As DataSetType,
 wso.pobject_name As DataSetName
From
 infodba.PDATASET pd
 INNER JOIN infodba.PREVISIONS rev On (pd.rrev_chain_anchoru = rev.puid) and (rev.pseq = 0)
 INNER JOIN infodba.PREF_LIST_0 rl On (rl.puid = pd.puid) and (rl.pseq = 0)
 INNER JOIN infodba.PDATASETTYPE pdt On (pd.rdataset_typeu = pdt.puid)
 INNER JOIN infodba.PIMANRELATION pr On (pr.rsecondary_objectu = pd.puid)
 INNER JOIN infodba.PIMANTYPE ptype On (ptype.puid = pr.rrelation_typeu)
 INNER JOIN infodba.PWORKSPACEOBJECT wso On (wso.puid = pd.puid)
 INNER JOIN infodba.PPOM_APPLICATION_OBJECT pao On (pao.puid = rev.pvalu_0)
 inner JOIN infodba.PITEMREVISION           ir    ON (pr.rprimary_objectu = ir.puid)
 inner JOIN infodba.PITEM           i    ON (i.puid = ir.ritems_tagu)
where
 pdt.pdatasettype_name = :para_object_Type and
 i.pitem_id = :para_item_id and
 ir.PITEM_REVISION_ID = :para_rev_id 
 /* #SQL.HINT.UGPartUGMan# */ and upper(ptype.ptype_name) = upper(:para_relation)
 /* #SQL.HINT.ObjectNameYes# */ and upper(wso.pobject_name) = upper(:object_name)     
 order by 
 pao.pcreation_date
