EssAsyncImportASO

Issues an asynchronous data load request on an aggregate storage database.

If you use asynchronous data loads and dimension builds, you can query for the following information during the process:

Syntax

ESS_FUNC_M EssAsyncImportASO (hCtx, pRules, pData, pUser, usAbortOnError, ulBufferId);
ParameterData TypeDescription

hCtx

ESS_HCTX_T

API context handle.

pRules

ESS_POBJDEF_T

Pointer to the rules file object definition structure.

pData

ESS_POBJDEF_T

Pointer to the data file object definition structure.

pUser

ESS_PMBRUSER_T

Pointer to the SQL user structure (if data source is a SQL database). A NULL SQL user structure indicates a non SQL data source.

usAbortOnError

ESS_USHORT_T

If TRUE, import stops on the first error. Otherwise, it continues.

ulBufferID

ESS_ULONG_T

ID of a data load buffer (a number between 1 and 999,999). To destroy a buffer before a data load is complete, you must use the same ulBufferId number that was used to initialize the buffer.

Notes

This function returns an error if the data object is located on the client. The network connection between client and server remains active even if an error is returned.

You must call EssCloseAsyncProc to close the connection; otherwise, the server request handler blocks further requests from the same login session.

Return Value

Returns zero if successful. Otherwise, returns an error code.

Access

This function requires the caller to have database designer privilege for the specified database (ESS_PRIV_DBDESIGN).

Example

void ESS_AsyncImportASO()
{
	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_STR_T errorName;
	ESS_BLDDL_STATE_T procState;
	ESS_BOOL_T errFileOverWrite;

	szAppName = "ASOSamp";
	szDbName = "Sample";
	ESS_SetActive();

	errorName = ".\\asyncProcess.err";
	errFileOverWrite = ESS_TRUE;
	ulDuplicateAggregationMethod = ESS_ASO_DATA_LOAD_BUFFER_DUPLICATES_ADD;
	ulOptionsFlags = ESS_ASO_DATA_LOAD_BUFFER_IGNORE_MISSING_VALUES;
	ulSize = 1;
	ulBufferId = 100;
	sts = EssLoadBufferInit(hCtx, szAppName, szDbName, ulBufferId, ulDuplicateAggregationMethod, 
		ulOptionsFlags, ulSize);
	printf("EssLoadBufferInit sts: %ld\n", sts);
	if(!sts)
	{
		/* Server object */
		Rules.hCtx     = hCtx;
		Rules.AppName  = szAppName;
		Rules.DbName   = szDbName;
		Rules.ObjType  = ESS_OBJTYPE_RULES;
		Rules.FileName = "Dataload";
		Data.hCtx      = hCtx;
		Data.AppName   = szAppName;
		Data.DbName    = szDbName;
		Data.ObjType   = ESS_OBJTYPE_TEXT;
		Data.FileName  = "Dataload";

		isAbortOnError = ESS_TRUE; 
		sts = EssAsyncImportASO (hCtx, &Rules, &Data, pMbrUser, isAbortOnError, ulBufferId);
		printf("EssAsyncImportASO sts: %ld\n",sts);
		if(!sts)
		{
			sts = EssGetAsyncProcState(hCtx, &procState);
			printf("EssGetAsyncProcState sts: %ld\n",sts);
			if(!sts)
			{
				do
				{
					DisplyProcesStateInfo(procState);
					if(procState.ilProcessStatus)
					{
						sts = EssCancelAsyncProc(hCtx, errorName, errFileOverWrite);
						printf("EssCancelAsyncProc sts: %ld\n",sts);
					}
					else
					{
						sts = EssGetAsyncProcState(hCtx, &procState);
						printf("EssGetAsyncProcState sts: %ld\n",sts);
					}

				}while(procState.usProcessState != ESS_BLDDL_STATE_DONE);

				sts = EssCloseAsyncProc(hCtx, &procState);
				printf("EssCloseAsyncProc sts: %ld\n",sts);

				ulBufferCnt = 1;
				ulBufferIdAry[0] = ulBufferId;
				ulCommitType = ESS_ASO_DATA_LOAD_BUFFER_STORE_DATA;
				ulActionType = ESS_ASO_DATA_LOAD_BUFFER_COMMIT;
				printf("\nIncrement to main slice:\n");
				ulOptions = ESS_ASO_DATA_LOAD_INCR_TO_MAIN_SLICE;
				sts = EssLoadBufferTerm(hCtx, szAppName, szDbName, ulBufferCnt, ulBufferIdAry, ulCommitType, ulActionType, ulOptions);
				printf("EssLoadBufferTerm sts: %ld\n",sts);
			}
		}
	}
}

See Also