Using AMO, I am trying to add new attributes to a dimension. It works fine if the dimension is a new dimension but if the dimension belongs to a cube, the Update method returns the following error:
Message "Errors in the metadata manager. The ALTER statement must be fully expanded because it will cause a structure change to the Gender dimension.
" String
StackTrace " at Microsoft.AnalysisServices.AnalysisServicesClient.SendExecuteAndReadResponse(ImpactDetailCollection impacts, Boolean expectEmptyResults, Boolean throwIfError)
at Microsoft.AnalysisServices.AnalysisServicesClient.Alter(IMajorObject obj, ObjectExpansion expansion, ImpactDetailCollection impact, Boolean allowCreate)
at Microsoft.AnalysisServices.Server.Update(IMajorObject obj, UpdateOptions options, UpdateMode mode, XmlaWarningCollection warnings, ImpactDetailCollection impactResult)
at Microsoft.AnalysisServices.Server.SendUpdate(IMajorObject obj, UpdateOptions options, UpdateMode mode, XmlaWarningCollection warnings, ImpactDetailCollection impactResult)
at Microsoft.AnalysisServices.MajorObject.Update(UpdateOptions options, UpdateMode mode, XmlaWarningCollection warnings)
at Microsoft.AnalysisServices.MajorObject.Update()

Modifying a dimension by adding a new attribute using AMO
Franz P.
Instead of
dim.Update()
try
db.Update(UpdateOption.ExpandFull)
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Vikramaditya
Can you post here sample of your code that is trying to update dimension and save changes back to the server
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Haribabu Chevuturi
Hi Edward,
Thank you very much for your help. In my previous message I made a mistake, instead of updating the whole database, I was trying to update the dimension only.
Again, thank you very much.
Abhishek Karnik
Using Microsoft sample:
I commented out the following piece of code:
//attr = dim.Attributes.Add("Weight");
//attr.KeyColumns.Add(CreateDataItem(db.DataSourceViews[0], "DimProduct", "Weight"));
//attr.AttributeHierarchyEnabled = false;
And then when the database is already processed:
db.Process();
static DataItem CreateDataItem(DataSourceView dsv, string tableName, string columnName)
{
DataTable dataTable = ((DataSourceView)dsv).Schema.Tables[tableName];
DataColumn dataColumn = dataTable.Columns[columnName];
return new DataItem(tableName, columnName,
OleDbTypeConverter.GetRestrictedOleDbType(dataColumn.DataType));
}
// Modifying a dimension by adding a new attribute
Dimension dim;
DimensionAttribute attr;
dim = db.Dimensions.GetByName("Product");
attr = dim.Attributes.Add("Weight");
attr.KeyColumns.Add(CreateDataItem(db.DataSourceViews[0], "DimProduct", "Weight"));
attr.AttributeHierarchyEnabled = false;
dim.Update();