CreateBlockLoader(
CurrentBlockKey: Integer;
TopBlockKey: Integer): IDimBlockLoader;
CurrentBlockKey — key of the current block.
TopBlockKey — key of top-level block.
The CreateBlockLoader method creates loader for lower-level elements.
This method is used to work with all types of Platform's dictionaries. The two parameters are explained by possibility of creating block hierarchy in other dictionary types. As calculated dictionaries do not support block hierarchy, key of the same dictionary block should be passed as values for both parameters.
Sub Makros_1(User: IUserDimension; Builder: IDimBuilder; Par: IMetabaseObjectParamValues);
Var
Mb: IMetabase;
Db: IDatabaseInstance;
Comm: IDalCommand;
Cur: IDalCursor;
Fields: IDalCursorFields;
DimBlock: IUserDimBlock;
BlockRoot, Block: IDimBlockLoader;
i: integer;
Begin
Mb:=MetabaseClass.Active;
Db:=MB.ItemById("S_X_D").Open(Null) As IDatabaseInstance;
Comm:=Db.Connection.CreateCommand("Select id, name, orders, parent_id From T_SEP Order by parent_id");
Cur:=Comm.CreateCursor;
Fields:=Cur.Fields;
DimBlock:=User.Blocks.Item(0);
BlockRoot:=Builder.CreateRootBlockLoader(DimBlock.Key);
Block:=Builder.CreateBlockLoader(DimBlock.Key,DimBlock.Key);
While Not cur.Eof Do
If (Fields.Item(3).Value As Double) = 0 Then
i:= BlockRoot.AddRow;
BlockRoot.Value(i, 0) := Fields.Item(0).Value As Double;
BlockRoot.Value(i, 1) := Fields.Item(1).Value As String;
BlockRoot.Value(i, 2) := Fields.Item(2).Value As Double;
Else
i:= Block.AddRow;
Block.Value(i, 0) := Fields.Item(0).Value As Double;
Block.Value(i, 1) := Fields.Item(1).Value As String;
Block.Value(i, 2) := Fields.Item(2).Value As Double;
Block.Value(i, 3) := Fields.Item(3).Value As Double;
End If;
Cur.Next;
End While;
End Sub Makros_1;
This example is a macro for calculated dictionary. The dictionary is based on the T_SEP table stored in the S_X_D database.
See also: