EssMergeDatabaseData

Merges two or more data slices into a single data slice. Optionally, the primary database slice can be excluded.

This function applies only to aggregate storage databases.

Syntax

ESS_FUNC_M EssMergeDatabaseData (hCtx, AppName, DbName, ulOptions);
ParameterData TypeDescription

hCtx

ESS_HCTX_T

API context handle

AppName

ESS_STR_T

Use NULL. Function always applies to the currently selected database.

DbName

ESS_STR_T

Use NULL. Function always applies to the currently selected database.

ulOptions

ESS_ULONG_T

One of the following constants:

  • #define ESS_MERGE_DATABASE_DATA_ALL 1: Merges all data slices into one.

  • #define ESS_MERGE_DATABASE_DATA_INCREMENTAL 2: Merges all incremental slices into one slice, but does not merge this slice with the primary slice. Afterwards, there will be two slices.

Return Value

Returns zero if successful; otherwise, returns an error code.

Example

void TestMergeDatabaseData(ESS_HCTX_T hCtx, ESS_STR_T AppName, ESS_STR_T DbName)
{
        ESS_STS_T               sts = ESS_STS_NOERR;
        ESS_SHORT_T             isAbortOnError;
        ESS_OBJDEF_T    Rules;
        ESS_OBJDEF_T    Data;
        ESS_PMBRERR_T   pMbrErr = NULL;
        ESS_PMBRUSER_T  pMbrUser = NULL;
        ESS_ULONG_T             ulBufferId;
        ESS_ULONG_T             ulDuplicateAggregationMethod;
        ESS_ULONG_T             ulOptionsFlags;
        ESS_ULONG_T             ulSize;
        ESS_ULONG_T             ulBufferCnt;
        ESS_ULONG_T             ulCommitType ;
        ESS_ULONG_T             ulActionType;
        ESS_ULONG_T             ulOptions;
        ESS_ULONG_T             ulBufferIdAry[1];
        ESS_ULONG_T             options;

        printf("\nCreate the buffer:\n");
        ulDuplicateAggregationMethod = ESS_ASO_DATA_LOAD_BUFFER_DUPLICATES_ADD;
        ulOptionsFlags = ESS_ASO_DATA_LOAD_BUFFER_IGNORE_MISSING_VALUES;
        ulSize = 100;
        ulBufferId = 1;
        sts = EssLoadBufferInit(hCtx, AppName, DbName, ulBufferId, ulDuplicateAggregationMethod, 
                ulOptionsFlags, ulSize);
        printf("EssLoadBufferInit sts: %ld\n", sts);

        /* Server object */
        Rules.hCtx     = hCtx;
        Rules.AppName  = AppName;
        Rules.DbName   = DbName;
        Rules.ObjType  = ESS_OBJTYPE_RULES;
        Rules.FileName = "ddldinaq";
        Data.hCtx      = hCtx;
        Data.AppName   = AppName;
        Data.DbName    = DbName;
        Data.ObjType   = ESS_OBJTYPE_TEXT;
        Data.FileName  = "ddldinaq_slice1a";
        isAbortOnError = ESS_TRUE; 

        printf("\nLoad into buffer:\n");
        sts = EssImportASO (hCtx, &Rules, &Data, &pMbrErr, pMbrUser, isAbortOnError, ulBufferId);
        printf("EssImportASO sts: %ld\n",sts);
        if(pMbrErr)
              EssFreeMbrErr(hCtx, pMbrErr);

        ulBufferCnt = 1;
        ulBufferIdAry[0] = ulBufferId;
        ulCommitType = ESS_ASO_DATA_LOAD_BUFFER_STORE_DATA;
        ulActionType = ESS_ASO_DATA_LOAD_BUFFER_COMMIT;
        printf("\Create a new slice:\n");
        ulOptions = ESS_ASO_DATA_LOAD_INCR_TO_NEW_SLICE;
        sts = EssLoadBufferTerm(hCtx, AppName, DbName, ulBufferCnt, ulBufferIdAry, ulCommitType,
                ulActionType, ulOptions);
        printf("EssLoadBufferTerm sts: %ld\n",sts);

        options = ESS_MERGE_DATABASE_DATA_ALL;
        printf("\nMerge all data into one slice:\n");
        sts = EssMergeDatabaseData(hCtx, AppName, DbName, options);
        printf("EssMergeDatabaseData sts: %ld\n",sts);
}

See Also