
-- IR has Solid Works DS
SELECT
 count (DISTINCT pd.puid)
FROM
 infodba.PDATASET pd
 Left Join infodba.PREVISIONS rev   On (rev.puid = pd.rrev_chain_anchoru)
 Left Join infodba.PREVISIONANCHOR  ra    On (ra.puid =  pd.rrev_chain_anchoru)
 Left Join infodba.PREF_LIST        rl    On (rl.puid = rev.pvalu_0) and (rl.pseq = 0)
 Left Join infodba.PREF_NAMES       rn    On (rn.puid = rl.puid And rl.pseq = rn.pseq)
 Left Join infodba.PDATASETTYPE     pdt   On (pdt.puid = pd.rdataset_typeu)
 Left Join infodba.PIMANRELATION    pr    On (pr.rsecondary_objectu = pd.puid)
 Left Join infodba.PIMANTYPE        ptype On (ptype.puid = pr.rrelation_typeu)
 Left Join infodba.PWORKSPACEOBJECT wso   On (wso.puid = pd.puid)
 Left Join infodba.PPOM_OBJECT      o     On (o.puid = pd.puid)
 Left Join infodba.PPOM_IMC         s     On (s.puid = o.rowning_siteu)
 Left Join infodba.PPOM_APPLICATION_OBJECT pao On (pao.puid = rev.pvalu_0)
 Left Join infodba.PPOM_USER     pu_owni_ds On (pu_owni_ds.puid = pao.rowning_useru)
 Left Join infodba.PPOM_USER     pu_lmod_ds On (pu_lmod_ds.puid = pao.rlast_mod_useru)
 Left Join infodba.PPOM_GROUP    pg_owni_ds On (pg_owni_ds.puid = pao.rowning_groupu)
WHERE
     pr.rprimary_objectu = :para_IrPuid
 and upper(pdt.pdatasettype_name) in ('SWPRT','SWASM','SWDRW')
;
