Navigating the Schema in OLE DB Scanner

Meta Data Services Programming

Meta Data Services Programming

Navigating the Schema in OLE DB Scanner

After the database schema has been scanned into a repository database, the schema can be easily navigated from Microsoft® Visual Basic® or Microsoft Visual C++® using the repository API. For example, the following Visual Basic code navigates in the following order: DataSource, Catalog, Schema, Table, Column, DataType.

Set IfD = Repos.object(OBJID_IDbmDataSource)
For Each datasource In IfD.ObjectInstances
  ...
  For Each catalog In datasource("_DataSource").DeployedCatalogs
    ...
    For Each schema In catalog("_Catalog").Schemas
      ...
      For Each table In schema("_Schema").Tables
        If QI(table, "IDbmTable") Then
          ...
          For Each column In table("_Table").Columns
            ...
            Set datatype = column("_Column").Attribute.Item(1)
          Next
        End If
      Next
    Next
  Next
Next

Private Function QI(o As RepositoryObject, name As String) As Boolean
On Error GoTo Fail
    Dim r As RepositoryObject
    Set r = o.Interface(name)
    QI = True
    Exit Function
Fail:
    QI = False
End Function