Delen via


clsCubeLevel

Note

  This feature will be removed in the next version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible.

An object of ClassType clsCubeLevel provides a specific implementation of the Decision Support Objects (DSO) Level interface. This object provides collections and properties through the Level interface. There are no methods associated with an object of ClassType clsCubeLevel.

Remarks

When a dimension within a database is assigned to a cube, the cube inherits all levels of the dimension. An object of ClassType clsCubeLevel allows access to these levels. Because not all database dimensions necessarily apply to a given cube, one advantage to accessing the levels of a cube directly is that you avoid traversing the dimensions and levels of the entire database to determine which levels are used in a cube.

Example

Use the following code to create a dimension and levels for a database and apply them to a cube:

'Assume an object (dsoDB) of ClassType clsDatabase exists
'with an existing data source
Dim dsoDim As DSO.Dimension
Dim dsoLevel As DSO.Level
Dim dsoDS As DSO.Datasource

'Add a dimension and levels to the database
Set dsoDS = dsoDB.Datasources(1)
Set dsoDim = dsoDB.Dimensions.AddNew("Products")
Set dsoDim.DataSource = dsoDS   'Dimension DataSource
dsoDim.FromClause = "product"   'Source Table

'Add a Product Brand Name level
Set dsoLev = dsoDim.Levels.AddNew("Brand Name")
dsoLev.MemberKeyColumn = """product"".""brand_name"""
dsoLev.ColumnSize = 255
dsoLev.ColumnType = adWChar
dsoLev.EstimatedSize = 100

'Add a Product Name level
Set dsoLev = dsoDim.Levels.AddNew("Product Name")
dsoLev.MemberKeyColumn = """product"".""product_name"""
dsoLev.ColumnSize = 255
dsoLev.ColumnType = adWChar
dsoLev.EstimatedSize = 1560
dsoDim.Update
'Add additional dimensions and levels as required
...
'Add cube to database
Dim dsoCube As MDStore
Set dsoCube = dsoDB.MDStores.AddNew(strCubeName)

'Create and configure a DataSource object for the cube
Set dsoDS = dsoDB.DataSources(1)
dsoCube.DataSources.AddNew (dsoDS.Name)

'Set source fact table and estimated rows in fact table
dsoCube.SourceTable = """sales_fact_1998"""
dsoCube.EstimatedRows = 1000
            
'Add shared database dimensions
'Cube inherits dimension levels
dsoCube.Dimensions.AddNew ("Products")
'Add other shared or private dimensions