ICubeInstanceStorage.Callback

Syntax

Callback: ICubeCallback;

Description

The Callback property determines a handler of the errors that may occur on saving data to cube.

Comments

As a property value, specify instance of the object that is inherited and redetermines properties and methods of the ICubeCallback interface or the CubeCallback class.

Handler of data saving to cube is set in the SaveMatrixCallback property. To handle errors and data saving process, one common handler inherited from the CubeCallback class can be used, but handler will work independently.

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;
    Mat: IMatrix;
    Coord: IMatrixCoord;
    Sto: ICubeInstanceStorage;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    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
    Mat := Des.Execute(Sels);
    Mat.ValueFlag := Mat.ValueFlag + 
1;
    
//Create a coordinate in matrix
    Coord := Mat.CreateCoord;
    
For i := 0 To Mat.DimensionCount - 1 Do
        Coord.Item(i) := 
0;
    
End For;
    
//Change value by coordinate
    Mat.Item(Coord) := (Mat.Item(Coord) As Double) + 1;
    Sto := Des.CreateStorage(CubeInstanceStorageOptions.NoCheckDuplicates);
    Sto.Callback := 
New TCubeCallback.Create;
    
//Save value
    Sto.SaveMatrix(Mat, Mat.ValueFlag);
End Sub UserProc;

Class TCubeCallback: CubeCallback
    
Public Sub OnCallback(Argument: ICubeCallbackArgument);
    
Begin
        Debug.WriteLine(
"Error: " + Argument.Error.Message);
        Debug.WriteLine(
"Error identifier: " + Argument.Error.MessageID.ToString);
        Debug.WriteLine(
"Source: " + Argument.Error.Source);
        Argument.IgnoreError := 
True;
    
End Sub OnCallback;

    
Public Function get_Argument: ICubeCallbackArgument;
    
Begin
        
Return Null;
    
End Function get_Argument;
End Class TCubeCallback;

After executing the example a matrix with cube data is obtained. The value is changed by some coordinate, following which an updated matrix is saved back to the cube. Duplicates availability is not checked during saving. Errors that may occur will be handled in the TCubeCallback custom class.

See also:

ICubeInstanceStorage