dbTalk Databases Forums  

Problem in copying a cube using Decision Support Objects (DSO)

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Problem in copying a cube using Decision Support Objects (DSO) in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Yash
 
Posts: n/a

Default Problem in copying a cube using Decision Support Objects (DSO) - 08-21-2003 , 12:31 AM






I have code that copies a cube and all its dimensions to a new cube ,
and adds the new cube to a newly created database. The database is
then added to the analysis server, all using the interface provided by
DSO. The database is UPDATEd after adding the new cube. I also process
the cube programmatically after changing the name of the fact table to
one a new one in the join and from clauses of the cube. While
debugging, I have verified that the join clause and from clause
correctly have the new fact table name. The operation succeeds without
problems and the cube gets listed when I open Analysis Manager.
However, when I right-click on the cube and choose Edit, the editor
does not show any tables in the designer pane, as if no joins have
been specified. When I try to process the cube through the editor, I
get an error saying a dimension table has not been joined to the fact
table.

Can someone suggest something I am leaving out? The original cube does
not have this problem, and the code that copies the cube is :

Public Function ProcessSelectedObjects(ByVal srcDB As String, ByVal
srcCube As String, ByVal destDB As String, ByVal destCube As String,
ByVal factTable As String) As Boolean

On Error GoTo cmdConnectToServer_Click_Err

dsoServer = New DSO.Server()
Dim srcDsodb As DSO.MDStore
Dim destDsodb As DSO.MDStore
Dim dsoCube As DSO.MDStore
Dim newDsoCube As DSO.MDStore
Dim dsoDbDim As DSO.Dimension
Dim dsoCubDim As DSO.Dimension
Dim dsoRole As DSO.Role
Dim tempRole As DSO.Role
Dim dsoDestRole As DSO.Role
factTable = """dbo""" & ".""" & factTable & """"


Dim dsoLDS As DSO.DataSource
Dim mes As Object
Dim dims As DSO.Dimension

Dim test As New System.Text.StringBuilder()

'Connect to the local analysis server
dsoServer.Name = System.Net.Dns.GetHostName()
dsoServer.Connect()


srcDsodb = dsoServer.MDStores.Item(srcDB)
dsoCube = srcDsodb.MDStores.Item(srcCube)

If (dsoServer.MDStores.Item(destDB) Is Nothing) Then
'create a new db
destDsodb = dsoServer.MDStores.AddNew(destDB)
srcDsodb.Clone(destDsodb,
DSO.CloneOptions.cloneMinorChildren)
End If

'add a new data db
destDsodb = dsoServer.MDStores.Item(destDB)
dsoLDS = destDsodb.DataSources.AddNew(destDB + " Data source")
dsoLDS.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=" +
config.sqlsDBName + ";Data Source=" & dsoServer.Name
dsoLDS.Update()

'update the private dimension names
For Each dims In srcDsodb.Dimensions
'add dimensions
If (dims.IsShared = False) Then
test = New System.Text.StringBuilder(dims.Name)
test.Replace(srcCube, destCube)
dsoDbDim = destDsodb.Dimensions.AddNew(test.ToString)
Else
dsoDbDim = destDsodb.Dimensions.AddNew(dims.Name)
End If
dims.Clone(dsoDbDim, DSO.CloneOptions.cloneMinorChildren)
dsoDbDim.DataSource = dsoLDS
dsoDbDim.Update()
Next
destDsodb.Update()


'add cube
newDsoCube = destDsodb.MDStores.AddNew(destCube)
dsoCube.Clone(newDsoCube, DSO.CloneOptions.cloneMinorChildren)





'update the data sources of the newly added dimensions
For Each dims In destDsodb.Dimensions
dims.DataSource = dsoLDS
Next


'update the datasource of the cube
newDsoCube.DataSources.AddNew(dsoLDS.Name)

For Each tempRole In newDsoCube.Roles
'delete roles
newDsoCube.Roles.Remove(tempRole.Name)
Next
newDsoCube.Update()






'remember the source fact table (only the fact table changes)
Dim srcTab As String = New String(newDsoCube.SourceTable)

For Each mes In newDsoCube.Measures
test = New
System.Text.StringBuilder(mes.SourceColumn.ToStrin g())
test.Replace(srcTab, factTable)
mes.SourceColumn = test.ToString
Next

test = New System.Text.StringBuilder(newDsoCube.SourceTableAl ias)
test.Replace(srcTab, factTable)
newDsoCube.SourceTableAlias = test.ToString

test = New System.Text.StringBuilder(newDsoCube.SourceTable)
test.Replace(srcTab, factTable)
newDsoCube.SourceTable = test.ToString

test = New System.Text.StringBuilder(newDsoCube.DrillThroughC olumns)
test.Replace(srcTab, factTable)
newDsoCube.DrillThroughColumns = test.ToString

test = New System.Text.StringBuilder(newDsoCube.DrillThroughF ilter)
test.Replace(srcTab, factTable)
newDsoCube.DrillThroughFilter = test.ToString

test = New System.Text.StringBuilder(newDsoCube.DrillThroughF rom)
test.Replace(srcTab, factTable)
newDsoCube.DrillThroughFrom = test.ToString


test = New System.Text.StringBuilder(newDsoCube.DrillThroughJ oins)
test.Replace(srcTab, factTable)
newDsoCube.DrillThroughJoins = test.ToString


test = New System.Text.StringBuilder(newDsoCube.FromClause)
test.Replace(srcTab, factTable)
newDsoCube.FromClause = test.ToString

test = New System.Text.StringBuilder(newDsoCube.JoinClause)
test.Replace(srcTab, factTable)
newDsoCube.JoinClause = test.ToString
newDsoCube.Update()


newDsoCube.Process()
Trace.WriteLine("Finished selective processing")

Return True

Exit Function
cmdConnectToServer_Click_Err:

Trace.WriteLine("Failed Processing Cube: " & "Error " &
Err.Number & ": " & Err.Description)

Return False



End Function

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.