# EsbCreateVariable

Description

EsbCreateVariable() creates a new substitution variable or modifies an existing substitution variable if the variable name already exists with the identical server, application, and database values.

Syntax

    EsbCreateVariable (hCtx, pVariable)

    ByVal hCtx      As Long
          pVariable As ESB_PVARIABLE_T

Parameters

hCtx | Essbase API context handle.
pVariable | Pointer to the structure containing the description of the substitution variable being created.

Return Value

If successful, returns zero.

Notes

- The scope of the variable can apply to the server, the application, or the database. The scope is controlled through the ESB_VARIABLE_T structure. When the server, application, and database are all named, the substitution variable applies only to the specified database. When only the server and application are named, the substitution variable applies to all databases in the specified application. When only the server is named, the substitution variable applies to all applications and databases on the specified server.
- When a variable exists and a new variable is created with the same name and scope, the new value replaces the old value with no error message from Esbbase.
- On a given server, you can create multiple substitution variables with the same name but different scopes (application and database).

Example

    Declare Function EsbCreateVariable Lib "esbapin" (ByVal hCtx As Long, pVariable As ESB_VARIABLE_T) As Long

    Sub Esb_CreateVariable()

    Dim sts As Long
    Dim oVariable As ESB_VARIABLE_T

    '  Create "QuarterName" Susbtitution Variable at the Sample application level
       oVariable.Server = "Localhost"
       oVariable.AppName = "Sample"
    '  ** Note that DbName has been left empty
       oVariable.VarName = "QuarterName"
       oVariable.VarValue = "Qtr1"

       sts = EsbCreateVariable(hCtx, oVariable)

    End Sub

See Also

ESB_VARIABLE_T
EsbDeleteVariable()
EsbGetVariable()
EsbListVariables()