RE: Processing error [Object does not exist] -
04-12-2004
, 03:22 PM
Michael,
I am creating a new partition within my Sales cube. This partition will
handle all of the data for a week. Below is the code I used to create
this within my dtspackage:
'DTSGlobalVariables("FactTable").Value = 'dbo.POS_FACT_2004_WK_12'
'DTSGlobalVariables("OLAP_Server").Value = 'ECKOLAP01'
'DTSGlobalVariables("OLAP_DB").Value = 'ECK_ODS'
'DTSGlobalVariables("SliceLevel").Value = 'All Fiscal Weeks.2004.APRIL -
2004.11'
'DTSGlobalVariables("SliceDim").Value = 'Fiscal Week'
'DTSGlobalVariables("PartitionName").Value = 'Sales_2004_12'
' Code Begins
On Error Resume Next
Dim intDimCounter, intErrNumber
Dim strOlapDB, strCube, strDB, strAnalysisServer, strPartitionNew,
strSliceValue, strDim
Dim dsoServer, dsoDB, dsoCube, dsoPartition, dsoPartitionNew,
dsoDimension
' Initialize server, database, and cube name variables.
strAnalysisServer = DTSGlobalVariables("OLAP_Server").Value
strOlapDB = DTSGlobalVariables("OLAP_DB").Value
strCube = DTSGlobalVariables("OLAP_Cube").Value
strSliceValue = DTSGlobalVariables("SliceLevel").Value
strDim = DTSGlobalVariables("SliceDim").Value
' Connect to the Analysis server.
Set dsoServer = CreateObject("DSO.Server")
dsoServer.Connect strAnalysisServer
' Ensure that a valid data source exists in the database.
Set dsoDB = dsoServer.mdStores(strOlapDB)
' Set the dsoCube variable to the desired cube.
Set dsoCube = dsoDB.MDStores(strCube)
' Set the dsoPartition variable to the desired partition.
Set dsoPartition = dsoCube.MDStores(dsoCube.MDStores.Count)
'Add for dimension
Set dsoDimension = dsoPartition.MDStores(strDim)
MsgBox "New partition will be based on existing partition: " &
chr(13) & chr(10) & dsoDB.Name & "." & dsoCube.Name & "." &
dsoPartition.Name, , "ClonePart.vbs"
' Get the quoting characters from the datasource, as
' different databases use different quoting characters.
Dim sLQuote, sRQuote
sLQuote = dsoPartition.DataSources(1).OpenQuoteChar
sRQuote = dsoPartition.DataSources(1).CloseQuoteChar
'************************************************* ********************
' Create the new partition based on the desired partition.
'************************************************* ********************
' Create a new, temporary partition.
strPartitionNew =
DTSGlobalVariables("PartitionName").Value '"NewPartition" &
dsoCube.MDStores.Count
Set dsoPartitionNew = dsoCube.MDStores.AddNew("~temp")
' Clone the properties from the desired partition to the new
partition.
dsoPartition.Clone dsoPartitionNew, cloneminorchildren
' Change the partition name from "~temp" to the name intended for the
new partition.
dsoPartitionNew.Name = strPartitionNew
dsoPartitionNew.AggregationPrefix = strPartitionNew & "_"
' Set the fact table for the new partition.
dsoPartitionNew.SourceTable = sLQuote &
DTSGlobalVariables("FactTable").Value & sRQuote
' Set the FromClause and JoinClause properties of the new partition.
dsoPartitionNew.FromClause = Replace(dsoPartition.FromClause,
dsoPartition.SourceTable, dsoPartitionNew.SourceTable)
dsoPartitionNew.JoinClause = Replace(dsoPartition.JoinClause,
dsoPartition.SourceTable, dsoPartitionNew.SourceTable)
'Sets the slicer for the partition
Set dsoDimension = dsoPartitionNew.Dimensions("Fiscal Week")
Set dsoLevel = dsoDimension.Levels("(All)")
dsoLevel.SliceValue = "All Fiscal Week"
Set dsoLevel = dsoDimension.Levels("Year")
dsoLevel.SliceValue = "2004"
Set dsoLevel = dsoDimension.Levels("Month.Fiscal Mth Abbr")
dsoLevel.SliceValue = "APRIL - 2004"
Set dsoLevel = dsoDimension.Levels("Week.Fiscal Wk Name")
dsoLevel.SliceValue = "12"
' Estimate the rowcount.
dsoPartitionNew.EstimatedRows = 18325
' Add another filter. The SourceTableFilter provides an additional
opportunity to add a WHERE clause to the SQL query that will
' populate this partition. We're using this filter to ensure our new
partition contains zero rows. For the purposes of this sample code
' we don't want to change the data in the FoodMart cube. Comment out
this line if you want to see data in the new partition.
' Save the partition definition in the metadata repository
dsoPartitionNew.Update
' Check the validity of the new partition structure.
IF dsoPartitionNew.IsValid Then
MsgBox "Partition is valid"
End If
MsgBox strPartitionNew & " has been created."
' The next statement, which is commented out, would process the
partition.
' In a real partition management system, this would likely be a
separate
' process, perhaps managed via DTS.
' dsoPartitionNew.Process
' Clean up.
Set dsoPartition = Nothing
Set dsoPartitionNew = Nothing
Set dsoCube = Nothing
Set dsoDB = Nothing
dsoServer.CloseServer
Set dsoServer = Nothing
Main = DTSTaskExecResult_Success
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! |