CREATE VIEW ADViewTypes AS 
  SELECT
    a.OVer,
    a.OID,
    b.oid as id,
    a.adViewName,
    a.adUserName,
    a.adOwningTool,
    a.adImpName
  FROM
    ADViewType a
    INNER JOIN ADViewRoot b ON b.OID=a.OID;

CREATE VIEW ADViewTypeTemp AS 
  SELECT
    a.OVer,
    a.OID,
    a.adViewName as name,
    a.adUserName as userName,
    a.adOwningTool as owningTool,
    b.adClassName,
    b.adLinkObject,
    d.adAttribName,
    d.adAttribViewName,
    d.adViewList
  FROM
    ADViewType a
    LEFT OUTER JOIN ADViewList b ON b.OID=a.adViewList
    LEFT OUTER JOIN ManyPtrTable c ON c.classAttrib='ADViewList.adViewElem' AND
      c.SourceOID=b.OID AND c.SourceOVer=b.OVer
    LEFT OUTER JOIN ADViewElem d ON d.OID=c.targetOID;

