Add([AddField: Boolean = True]): IMetaAttribute;
AddField - parameter that determines whether a new field in the table is created to store attribute values.
Default value is True, at the same time a new field is created in a table.
If the value is False, a field is not created. To create a new table or update a current one, after changing the attributes list, it is necessary to call the CreateTable method (the BuildFieldsByAttributes method can be used to update fields list in an existing table).
The Add method adds an attribute to the collection.
Executing the example requires that the repository contains a time series database with the OBJ_FC identifier and an MDM repository with the RDS_REPO identifier. The MDM repository must contain a dictionary with the DICT_COUNTRY identifier.
Sub Main;
Var
MB: IMetabase;
Rubr: IRubricator;
Facts: IMetabaseObject;
Att: IMetaAttribute;
CollectionAtt: IMetaAttributes;
Begin
MB := MetabaseClass.Active;
Rubr := MB.ItemById("OBJ_FC").Bind As IRubricator;
Facts := (Rubr.Facts As IMetabaseObject).Edit;
Att := (Facts As IMetaDictionary).Attributes.Add;
Att.DataType := DbDataType.Integer;
Att.Id := "A_M_REF";
Att.Name := New attribute;
Att.Kind := (MetaAttributeKind.Collection) Or (MetaAttributeKind.Dimension);
Att.ValuesObject := MB.ItemByIdNamespace("DICT_COUNTRY", Mb.ItemById("RDS_REPO").Key);
Att.DataType := DbDataType.Integer;
Att.HasMultipleValues := True;
CollectionAtt := Att.CollectionAttributes;
CollectionAtt.BuildCollectionAttributes;
CollectionAtt.CreateTable(True);
Facts.Save;
End Sub Main;
After executing the example, an attribute named New Attribute is added to the dictionary that contains information about database time series with the OBJ_FC identifier. This attribute is a link to the dictionary and supports multiple values. A system table is also created to store multiple values of a new attribute.
See also: