473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating a new partition in an OLAP database

I am trying to write a C# backend program that will handle the
database maintenance that I would otherwise have to do via Microsoft's
Analysis Services front end GUI Wizards. Currently I am having a
problem with recreating the SliceValue. The value is a time dimension
and should equate to [Monthly Dates].[Year].[Quarter].[Month] and
instead it is these same values, but instead of being seperated by
periods it has some sort of non-displayable character (maybe a
newline) that is placing each value on a new line. The error I
receive when I attempt to process the partition is as follows:

An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
ProcessCubes.exe

Additional information: Processing error [Object does not exist]
'[All]
[2003]
[Quarter 2]
[May]'

The code is below.

public void ProcessCubeIncremental(string ServerName, string
DatabaseName, string Frequency, string CubeName, string FactTableName,
string ReportDate)
{
DSO.ServerClass dsoServer = new DSO.ServerClass();
DSO.MDStore dsoDatabase;
DSO.MDStore dsoCube;
DSO.MDStore dsoPartitionNew;
DSO.MDStore dsoPartitionOld;
DSO.Dimension dsoDimension;
DSO.Level dsoLevel;
//DSO.Level dsoLevelAll;
//DSO.Level dsoLevelYear;
//DSO.Level dsoLevelQuarter;
//DSO.Level dsoLevelMonth;
DSO.Property dsoProperty;
DateTime dt = Convert.ToDateTime(ReportDate);
GregorianCalendar c = new
GregorianCalendar(GregorianCalendarTypes.Localized );
int YearOld = c.GetYear(c.AddMonths(dt,-1));
int MonthOld = c.GetMonth(c.AddMonths(dt,-1));
string YearOldStr = YearOld.ToString();
string MonthOldStr;
if (MonthOld < 10)
{
MonthOldStr = "0"+MonthOld.ToString();
}
else
{
MonthOldStr = MonthOld.ToString();
}
int YearNew = c.GetYear(dt);
int MonthNew = c.GetMonth(dt);
string YearNewStr = YearNew.ToString();
string MonthNewStr;
if (MonthNew < 10)
{
MonthNewStr = "0"+MonthNew.ToString();
}
else
{
MonthNewStr = MonthNew.ToString();
}

switch(MonthNew)
{
case 1:
MonthNewName = "January";
break;
case 2:
MonthNewName = "February";
break;
case 3:
MonthNewName = "March";
break;
case 4:
MonthNewName = "April";
break;
case 5:
MonthNewName = "May";
break;
case 6:
MonthNewName = "June";
break;
case 7:
MonthNewName = "July";
break;
case 8:
MonthNewName = "August";
break;
case 9:
MonthNewName = "September";
break;
case 10:
MonthNewName = "October";
break;
case 11:
MonthNewName = "November";
break;
case 12:
MonthNewName = "December";
break;
}

string PartitionNameOld = "p"+YearOldStr+MonthOldStr;
string PartitionNameNew = "p"+YearNewStr+MonthNewStr;
string ReportDateStart = MonthNewStr+"/1/"+YearNewStr;
string ReportDateRange;
string ReportDateEnd =
MonthNewStr+"/"+c.GetDaysInMonth(YearNew,MonthNew).ToString( )+"/"+YearNewStr;
if (Frequency == "Daily")
{
ReportDateRange = "between '" + ReportDateStart + "' and '" +
ReportDateEnd + "'";
}
else
{
ReportDateRange = "= '" + ReportDateEnd + "'";
}
// Connect to the local server
dsoServer.Connect(ServerName);

// Set up the MDStore objects:
// database, cube, and partition.
dsoDatabase = (DSO.MDStore) dsoServer.MDStores.Item(DatabaseName);
dsoCube = (DSO.MDStore) dsoDatabase.MDStores.Item(CubeName);
dsoPartitionOld = (DSO.MDStore)
dsoCube.MDStores.Item(PartitionNameOld);
// delete the partition if it already exists
if (dsoCube.MDStores.Find(PartitionNameNew) == true)
{
dsoCube.MDStores.Remove(PartitionNameNew);
}

// Create a new partition.
dsoPartitionNew = (DSO.MDStore) dsoCube.MDStores.AddNew("~temp",
DSO.SubClassTypes.sbclsRegular);

// Clone the properties from the desired partition to the new
partition.
dsoPartitionOld.Clone(dsoPartitionNew,
DSO.CloneOptions.cloneMajorChildren);

// Change the partition name from "~temp" to the name intended for
the new partition.
dsoPartitionNew.Name = PartitionNameNew;
dsoPartitionNew.AggregationPrefix = PartitionNameNew+"_";

//dsoPartitionNew.SourceTable = "\"dbo\".\""+FactTableName+"\"";
dsoPartitionNew.SourceTable = "\""+FactTableName+"\"";

// Estimate the rowcount from the reference partition.
dsoPartitionNew.EstimatedRows = dsoPartitionOld.EstimatedRows;

dsoPartitionNew.SourceTableFilter = dsoPartitionNew.SourceTable +
".\"ReportDate\" " + ReportDateRange;

// Set the FromClause and JoinClause properties of the new
partition.
//dsoPartitionNew.FromClause =
dsoPartitionOld.FromClause.Replace(dsoPartitionOld .SourceTable,
dsoPartitionNew.SourceTable);
//dsoPartitionNew.JoinClause =
dsoPartitionOld.JoinClause.Replace(dsoPartitionOld .SourceTable,
dsoPartitionNew.SourceTable);

// Change the definition of the data Slice used by the new
partition.
// Change the SliceValue properties of the affected levels and
dimensions to the correct values.
switch(MonthNew)
{
case 1:
case 2:
case 3:
Quarter = 1;
break;
case 4:
case 5:
case 6:
Quarter = 2;
break;
case 7:
case 8:
case 9:
Quarter = 3;
break;
case 10:
case 11:
case 12:
Quarter = 4;
break;
}

// Change the definition of the data slice used by the new
// partition, by changing the SliceValue properties of the
// affected levels and dimensions to the desired values.
dsoDimension = (DSO.Dimension)
dsoPartitionNew.Dimensions.Item("Monthly Dates");
dsoDimension.CustomProperties.Clear();
//dsoDimension.CustomProperties.Remove("SliceValue") ;
//dsoDimension.CustomProperties.Add("[All].["+YearNewStr+"].Quarter
"+Quarter.ToString()+"].["+MonthNewStr+"]","SliceValue",VBA.VbVarType.vbString);
//dsoLevels = (DSO.Level)
dsoDimension.Levels.Item("(All).Year.Quarter.Month ");
//dsoLevels.SliceValue = "[All].["+YearNewStr+"].[Quarter
"+Quarter.ToString()+"].["+MonthNewName+"]";
//dsoProperty = (DSO.Property)
dsoDimension.CustomProperties.Add("[All]","(All)",VBA.VbVarType.vbString);
//dsoProperty = (DSO.Property)
dsoDimension.CustomProperties.Add("["+YearNewStr+"]","Year",VBA.VbVarType.vbString);
//dsoProperty = (DSO.Property)
dsoDimension.CustomProperties.Add("[Quarter
"+Quarter.ToString()+"]","Quarter",VBA.VbVarType.vbString);
//dsoProperty = (DSO.Property)
dsoDimension.CustomProperties.Add("["+MonthNewName+"]","Month",VBA.VbVarType.vbString);
dsoLevel = (DSO.Level) dsoDimension.Levels.Item("(All)");
dsoLevel.SliceValue = "[All]";
dsoLevel = (DSO.Level) dsoDimension.Levels.Item("Year");
dsoLevel.SliceValue = "["+YearNewStr+"]";
dsoLevel = (DSO.Level) dsoDimension.Levels.Item("Quarter");
dsoLevel.SliceValue = "[Quarter "+Quarter.ToString()+"]";
dsoLevel = (DSO.Level) dsoDimension.Levels.Item("Month");
dsoLevel.SliceValue = "["+MonthNewName+"]";
//dsoLevelAll = (DSO.Level) dsoDimension.Levels.Item("(All)");
//dsoLevelAll.SliceValue = "[All]";
//dsoLevelYear = (DSO.Level) dsoDimension.Levels.Item("Year");
//dsoLevelYear.SliceValue = "["+YearNewStr+"]";
//dsoLevelQuarter = (DSO.Level)
dsoDimension.Levels.Item("Quarter");
//dsoLevelQuarter.SliceValue = "[Quarter "+Quarter.ToString()+"]";
//dsoLevelMonth = (DSO.Level) dsoDimension.Levels.Item("Month");
//dsoLevelMonth.SliceValue = "["+MonthNewName+"]";

// Save the partition definition in the metadata repository.
dsoPartitionNew.Update();

// Process the temporary partition.
//dsoCube.LockObject(DSO.OlapLockTypes.olapLockProce ss, "Processing
object...");
dsoPartitionNew.Process(DSO.ProcessTypes.processFu ll);

//dsoCube.UnlockObject();

// Close the allocated resources and exit the subroutine.
dsoCube = null;
dsoDatabase = null;
dsoServer.CloseServer();
dsoServer = null;
}

Please help me, I'm a desparate man!
Nov 15 '05 #1
1 5659
jagan
1
Hi Mark,

This is Jagan. I too had a similar problem. I don't know whether u solved it or not.
But it has a solution. Don't add slices one by one to the dimension. Instead use custom properties of the dimension. Here is the code snippet:

dsoDimension.CustomProperties.Clear();
dsoDimension = (DSO.Dimension)dsoPartitionNew.Dimensions.Item("di mTime");
dsoDimension.CustomProperties.Add("All dimTime.2006.Quarter 2.April.19", "DimensionSlice", VBA.VbVarType.vbString);
dsoDimension = (DSO.Dimension)dsoPartitionNew.Dimensions.Item("di mEntities");
dsoDimension.CustomProperties.Add("All dimEntities.ITC.ITC", "DimensionSlice", VBA.VbVarType.vbString);

dsoPartitionNew.Update();
dsoPartitionNew.Process(DSO.ProcessTypes.processFu ll);

This solved my problem.

Regards,

Jagan
Jul 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Syed Mudussir Husain | last post by:
Hello, I am doing a very large web based database project. Over the period of 5 years, "more than 100, 000 Books" will be stored in a Database along with a LARGE amount of book attributes...
7
by: Will | last post by:
On the subject of Data Warehouses, Data Cubes & OLAP…. I would like to speak frankly about Data Warehouses, Data Cubes and OLAP (on-line analytical processing). Has it dawned on anyone else...
6
by: Dim St Thomas | last post by:
I am a developer working on a database client program. I am testing this program on a Windows XP machine (1.5 GHz AMD chip, 480 Mb RAM, 60 Gb disk) This machine has Oracle 9.2.0.1.0 and RedBrick...
7
by: Will | last post by:
On the subject of Data Warehouses, Data Cubes & OLAP…. I would like to speak frankly about Data Warehouses, Data Cubes and OLAP (on-line analytical processing). Has it dawned on anyone else...
5
by: Framework fan | last post by:
Hello, If I wrote the next ebay (yes I know, yawn-snore) and I had a database with 5 million auction items in it, what would be a really good strategy to get a search done very quickly? Would...
0
by: YellowFin Announcements | last post by:
Yellowfin Reporting Announces Release 3 OLAP Connectivity New Features Including OLAP-to-Relational Drill Through Provide Customers with One Complete Web BI Tool for OLAP Analysis Yellowfin,...
0
by: YellowFin | last post by:
Yellowfin Announces Release 3 OLAP Connectivity New Features Including OLAP-to-Relational Drill Through Provide Customers with One Complete Web BI Tool for OLAP Analysis Yellowfin, today...
7
by: Gladiator | last post by:
Hai all, I have Db2 installed in a partition environment . There are 4 partitons on which i created the instance. can any one tell me if i can create a database on the required partitons .........
1
by: Laurence | last post by:
Hi folks, As I konw: database partition (aka data partition?), the database can span multiple machines; table partition, the data within a table can seperate by certain condition. How about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.