# EssCalc

Description

EssCalc() sends and optionally executes a calc script against the active database as a single string. This function is equivalent to making a call to EssBeginCalc(), followed by calls to EssSendString(), and finally to EssEndCalc(). The calculation can either be initiated, or the calc script can just be verified and any errors returned.

Syntax

    ESS_FUNC_M EssCalc (hCtx, Calculate, CalcScript);

ESS_HCTX_T | hCtx
ESS_BOOL_T | Calculate
ESS_STR_T | CalcScript

Parameters

hCtx | Essbase API context handle.
Calculate | Controls calculation of the calc script. If TRUE, the calc script is executed.
CalcScript | The calc script, as a single string (must be less than 64 Kbytes).

Return Value

None.

Notes

- The calc script string must be less than 64 Kbytes long.
- If this function succeeds and the calculation is started, it will continue on the server as an asynchronous process after the return from this call. The caller must check at regular intervals to see if the process has completed by calling EssGetProcessState() until it returns ESS_STATE_DONE.
- If the Calculate flag is set to FALSE, the database merely performs a syntax check of the calc script.

Access

This function requires the caller to have calc privilege (ESS_PRIV_CALC) to the active database.

Example

    ESS_FUNC_M
    ESS_CalcLine   (ESS_HCTX_T            hCtx)
    {
       ESS_FUNC_M        sts = ESS_STS_NOERR;
       ESS_STR_T        Script;
       ESS_PROCSTATE_T  pState;

       Script = "CALC ALL;";
       sts = EssCalc(hCtx, ESS_TRUE, Script);
       if (!sts)
       {
          sts = EssGetProcessState (hCtx, &pState);
          while (!sts || (pState.State !=
                  ESS_STATE_DONE))
            sts = EssGetProcessState (hCtx, &pState);
       }
       return(sts);
    }

See Also

EssBeginCalc()
EssCalcFile()
EssDefaultCalc()
EssEndCalc()
EssGetDefaultCalc()
EssGetProcessState()
EssSendString()
EssSetDefaultCalc()