IRdsAttribute.Calculated

Fore Syntax

Calculated: Boolean;

Fore.NET Syntax

Calculated: boolean;

Description

The Calculated property determines whether the attribute is a calculated one.

Comments

Available values:

Text of the query used to calculate attribute value, is defined in the IRdsAttribute.Query property. You cannot set value of a calculated attribute. If the query contains main table fields and borrowed fields, the #TABLE# mask should be used before the main fields.

If the dictionary includes calculated attributes, it is reloaded on adding or editing an element.

Fore Example

Executing the example requires that repository contains an MDM repository with the RDS identifier, that contains a table MDM dictionary with the DICT identifier.

Add links to the Metabase, Rds, Dal system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    RdsKey: Integer;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Attrs: IRdsAttributes;
    Attr: IRdsAttribute;
Begin
    MB := MetabaseClass.Active;
    RdsKey := MB.GetObjectKeyById("RDS");
    MObj := MB.ItemByIdNamespace("DICT", RdsKey).Edit;
    Dict := MObj As IRdsDictionary;
    Attrs := Dict.Attributes;
    Attr := Attrs.Add;
    Attr.DataType := DbDataType.Integer;
    Attr.Id := "CALC_ATTR";
    Attr.Name := "Calculated attribute";
    Attr.Calculated := True;
    Attr.Query := "#TABLE#.KEY + 1";
    MObj.Save;
End Sub UserProc;

After executing the example a calculated attribute with the CALC_ATTR identifier is added to the MDM dictionary. Attribute value is based on the following formula:element key value + 1.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Rds;

[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    RdsKey: uinteger;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Attrs: IRdsAttributes;
    Attr: IRdsAttribute;
Begin
    MB := Params.Metabase;
    RdsKey := MB.GetObjectKeyById("RDS");
    MObj := MB.ItemByIdNamespace["DICT", RdsKey].Edit();
    Dict := MObj As IRdsDictionary;
    Attrs := Dict.Attributes;
    Attr := Attrs.Add();
    Attr.DataType := DbDataType.ddtInteger;
    Attr.Id := "CALC_ATTR";
    Attr.Name := "Calculated attribute";
    Attr.Calculated := True;
    Attr.Query := "#TABLE#.KEY + 1";
    MObj.Save();
End Sub;

See also:

IRdsAttribute