ICubeInstanceStorage.SaveMatrixT

Syntax

SaveMatrixT(Matrix: IMatrix; Manager: ICubeTransactionManager; ValueFlag: Integer);

Parameters

Matrix. Matrix containing values that must be saved back to cube.

Manager. Transaction manager instance that will trace cube operations.

ValueFlag. Flag of elements containing changed data. Only the matrix elements are saved to cube, which flag corresponds to this value.

Description

The SaveMatrixT method saves data matrix to cube using the transaction manager.

Example

Executing the example requires that the repository contains a cube with the STD_CUBE identifier.

Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    CubInst: ICubeInstance;
    Des: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    Sel: IDimSelection;
    Matr: IMatrix;
    Coord: IMatrixCoord;
    Sto: ICubeInstanceStorage;
    TransMan: ICubeTransactionManager;
    i: Integer;
Begin
    Mb := MetabaseClass.Active;
    
//Cube, in which data is changed
    CubInst := MB.ItemById("STD_CUBE").Open(NullAs ICubeInstance;
    Des := CubInst.Destinations.DefaultDestination;
    Sels := Des.CreateDimSelectionSet;
    
For Each Sel In Sels Do
        Sel.SelectElement(
0False);
    
End For;
    
//Get values matrix by specified selection
    Matr := Des.Execute(Sels);
    Matr.ValueFlag := Matr.ValueFlag + 
1;
    
//Create a coordinate in matrix
    Coord := Matr.CreateCoord;
    
For i := 0 To Matr.DimensionCount - 1 Do
        Coord.Item(i) := 
0;
    
End For;
    
//Change value by coordinate
    Matr.Item(Coord) := (Matr.Item(Coord) As Double) + 1;
    Sto := Des.CreateStorage(CubeInstanceStorageOptions.None);
    //Save value using transaction manager
    TransMan := New CubeTransactionManager.Create;
    
Try
        Sto.SaveMatrixT(Matr, TransMan, Matr.ValueFlag);
        TransMan.Commit;
    
Except
        
//Roll back transaction (undo changes)
        TransMan.Rollback;
    
End Try;
End Sub UserProc;

After executing the example a matrix with cube data is obtained. The value is changed by some coordinate, following which the updated matrix is saved back to the cube. Saving is executed using the transaction manager that saves all changes and finishes transaction if data is saved successfully. If some errors occur, the transaction manager cancels all changes.

See also:

ICubeInstanceStorage