Udostępnij przez


Praca z wymiarami wirtualnych

Ostrzeżenie

  Ta funkcja zostanie usunięta z następnej wersji programu Microsoft SQL Server. Nie należy stosować tej funkcji w nowych projektach oraz jak najszybciej należy zmodyfikować aplikacje, w których obecnie jest używana ta funkcja.

Kroki tworzenia wirtualnego wymiary z Decision Support Objects (DSO) są podobne do tych używane do tworzenia regularnych wymiarów.Tworzenie wirtualnego wymiaru na podstawie kolumn inny wymiar, utworzyć wymiar normalnie, ale ustawić IsVirtual właściwość na wartość True i zestaw DependsOnDimension Właściwości nazwę źródło wymiaru.Tworzenie wirtualnego wymiar oparte na właściwościach element członkowski wymiar regularnych jest bardziej skomplikowane.Procedura zobrazowano przykładowy kod na końcu tego tematu.

Różnice wirtualnego wymiary

Ponieważ wirtualnego wymiar jest na podstawie zawartości istniejącego wymiar, wiele właściwości dla wirtualnego wymiar obiektu i jego obiektów poziom są tylko do odczytu i nie trzeba być zestaw przed przetworzeniem wymiar.Pozostałe właściwości wymiar i poziom obiektów należy ustawić odnoszą się do podstawowych właściwości wymiar lub członka, które zapewniają źródło danych dla wirtualnego wymiar.

Następujące tabela zawiera listę właściwości wymiar i poziom, które są tylko do odczytu lub jest ignorowana dla wirtualnego wymiar.

właściwość obiektu

Opis

Dimension.FromClause

Tylko do odczytu.Jest pobierana z źródło wymiar.

Dimension.IsChanging

Zawsze PRAWDZIWE wirtualnego wymiar utworzonych przy użyciu programu Microsoft ® SQL Server ™ 2000 Analysis Services.

Dimension.JoinClause

Tylko do odczytu.Jest pobierana z źródło wymiar.

Dimension.StorageMode

Zawsze storeasMOLAP dla wirtualnego wymiar.

Dimension.SourceTableFilter

Tylko do odczytu.Jest pobierana z źródło wymiar.

Dimension.SourceTableAlias

Tylko do odczytu.Jest pobierana z źródło wymiar.

Level.EstimatedSize

Nie używany dla poziom wirtualnego wymiar.

Level.Grouping

Zawsze groupingNone dla poziom wirtualnego wymiar.

Level.HideMemberIf

Zawsze hideNever dla poziom wirtualnego wymiar.

Dodać wirtualnego wymiaru

Poniższy przykład kodu umożliwia utworzenie wirtualnego wymiar.Wirtualnego wymiaru, z wyjątkiem jak zaznaczono w tabela, jest traktowana jako drugi wymiar.

Poniższy przykład kodu tworzy wymiar magazynu wirtualnego wymiar SQFT w TestDB bazy danych.Ten wymiar wirtualnego jest oparty na właściwości element członkowski, Store SQFT magazynów źródło wymiaru:

Private Sub AddVirtualDimension()
    Dim dsoServer As New DSO.Server
    Dim dsoDB As DSO.MDStore
    Dim dsoDS As DSO.DataSource
    Dim dsoDim As DSO.Dimension
    Dim dsoLevel As DSO.Level

    Dim strDBName As String
    Dim strLQuote As String
    Dim strRQuote As String

    ' Define constants used for the ColumnType property
    ' of the DSO.Level object.
    ' Note that these constants are identical to
    ' those used in ADO in the DataTypeEnum enumeration.
    Const adDouble = 5

    ' Initialize variable for the database.
    strDBName = "TestDB"

    ' Create a connection to the Analysis server.
    dsoServer.Connect "LocalHost"

    ' Ensure that the server has an existing database.
    If dsoServer.MDStores.Find(strDBName) = False Then
        MsgBox "Database " & strDBName & _
            " is not found."
    Else
        ' Retrieve the database from the server.
        Set dsoDB = dsoServer.MDStores(strDBName)

        ' Retrieve a data source from the database.
        Set dsoDS = dsoDB.DataSources("FoodMart")

        ' Get the delimiter characters from the data source.
        strLQuote = dsoDS.OpenQuoteChar
        strRQuote = dsoDS.CloseQuoteChar

        ' Create the new dimension in the Dimensions
        ' collection of the database object.
        Set dsoDim = dsoDB.Dimensions.AddNew("Store Size in SQFT")

        ' Set the description of the dimension.
        dsoDim.Description = "The Store Size in SQFT virtual dimension"

        ' Set the data source of the dimension.
        Set dsoDim.DataSource = dsoDS

        ' Set the dimension type, make it virtual,
        ' and identify its underlying source dimension.
        dsoDim.DimensionType = dimRegular
        dsoDim.IsVirtual = True
        dsoDim.DependsOnDimension = "Stores"

        ' Next, create the levels.
        ' Start with the (All) level.
        Set dsoLevel = dsoDim.Levels.AddNew("(All)")

        ' Set the level type.
        dsoLevel.LevelType = levAll

        ' Set the MemberKeyColumn of the (All) level to a constant
        ' that also acts as the name of the level's only member.
        dsoLevel.MemberKeyColumn = "(All Store Sizes)"

        ' Create the Store SQFT level. This holds the SQFT value.
        Set dsoLevel = dsoDim.Levels.AddNew("Store Size")

        ' Name the source column for this level.
        ' The format for this is "table_name"."column_name".
        ' Database-specific delimiter characters are required.
        dsoLevel.MemberKeyColumn = strLQuote & "store" & strRQuote & "." & _
                                   strLQuote & "store_sqft" & strRQuote

        ' Set the following properties to be identical to their
        ' counterparts in the member property object that provides
        ' this level with its data.
        dsoLevel.ColumnType = adDouble
        dsoLevel.ColumnSize = 4

        ' Check to see that you set the level and
        ' dimension properties correctly, and that the rest
        ' of the dimension structure is correct. If so,
        ' update the repository and exit the function.
        If dsoLevel.IsValid And dsoDim.IsValid Then
            ' Update the dimension.
            dsoDim.Update

            ' Inform the user.
            MsgBox "Virtual dimension has been added."
        End If
    End If

End Sub