代替変数を新規作成、または同一のサーバー値、アプリケーション値およびデータベース値を持つ変数名がすでに存在している場合には既存の代替変数を変更します。
構文
ESS_FUNC_M EssCreateVariable (
hCtx, pVariable
);
| パラメータ | データ型 | 説明 |
|---|---|---|
hCtx |
ESS_HCTX_T |
APIコンテキスト・ハンドル。 |
pVariable |
ESS_PVARIABLE_T |
作成された代替変数の説明を含む構造体を指すポインタ。 |
備考
変数範囲はサーバー、アプリケーション、またはデータベースに適用できます。範囲はESS_VARIABLE_T構造体で制御されます。サーバー、アプリケーション、データベースがすべて指定されている場合は、代替変数は指定されたデータベースにのみ適用されます。サーバーとアプリケーションのみが指定されている場合、代替変数は指定されたアプリケーション内のすべてのデータベースに適用されます。サーバーのみが指定されている場合、代替変数は指定されたサーバーのすべてのアプリケーションとデータベースに適用されます。
新規変数が既存の変数と同じ名前および適用範囲で作成された場合、Essbaseからエラー・メッセージは戻されずに新しい値で古い値が置換されます。
指定した1台のサーバー上では、同じ名前で適用範囲(アプリケーションとデータベース)の異なる複数の代替変数を作成できます。
戻り値
成功の場合、ゼロが戻されます。
例
/*
** ESS_CreateVariable() creates a substitution variable using
** the API EssCreateVariable, and sets its value.
*/
ESS_FUNC_M
ESS_CreateVariable (ESS_HCTX_T hCtx)
{
ESS_FUNC_M sts = ESS_STS_NOERR;
ESS_VARIABLE_T Variable;
printf("\n ******************************************");
printf("\n **** An example of using EssCreateVariable");
printf("\n ******************************************");
/* Create Variable 'QuarterName' at the level of the server/App/Db */
strcpy(Variable.VarName, "QuarterName");
strcpy(Variable.Server, "Local");
strcpy(Variable.AppName, "Sample");
strcpy(Variable.DbName, "Basic");
strcpy(Variable.VarValue, "Qtr1");
sts = EssCreateVariable(hCtx, &Variable);
if (sts == ESS_STS_NOERR)
printf("\n Variable 'QuarterName' is created at the Server/App/Db level
with value 'Qtr1'");
/* Change Value of 'QuarterName' from Qtr1 to Qtr2 */
if (sts == ESS_STS_NOERR)
{
strcpy(Variable.VarName, "QuarterName");
strcpy(Variable.Server, "Local");
strcpy(Variable.AppName, "Sample");
strcpy(Variable.DbName, "Basic");
strcpy(Variable.VarValue, "Qtr2");
sts = EssCreateVariable(hCtx, &Variable);
if (sts == ESS_STS_NOERR)
printf("\n Variable 'QuarterName' at the Server/App/Db level is updated
to value 'Qtr2'");
}
/* Create Variable 'MarketName' at the level of the Server/App */
if (sts == ESS_STS_NOERR)
{
strcpy(Variable.VarName, "MarketName");
strcpy(Variable.Server, "Local");
strcpy(Variable.AppName, "Sample");
strcpy(Variable.DbName, "");
strcpy(Variable.VarValue, "East");
sts = EssCreateVariable(hCtx, &Variable);
if (sts == ESS_STS_NOERR)
printf("\n Variable 'MarketName' is created at the Server/App level");
}
/* Create Variable "MarketName' at the level of the Server */
/* This shows that you can have the same variable name at different levels*/
if (sts == ESS_STS_NOERR)
{
strcpy(Variable.VarName, "MarketName");
strcpy(Variable.Server, "Local");
strcpy(Variable.AppName, "");
strcpy(Variable.DbName, "");
strcpy(Variable.VarValue, "Market");
sts = EssCreateVariable(hCtx, &Variable);
if (sts == ESS_STS_NOERR)
printf("\n Variable 'MarketName' is created at the Server level");
}
if (sts == ESS_STS_NOERR)
printf("\n --> No Errors in EssCreateVariable\n\n\n");
else
printf("\n --> Error in EssCreateVariable number: %d\n\n\n", sts);
return (sts);
} /* end ESS_CreateVariable */
出力
******************************************
**** An example of using EssCreateVariable
******************************************
Variable 'QuarterName' is created at the Server/App/Db level with value 'Qtr1'
Variable 'QuarterName' at the Server/App/Db level is updated to value 'Qtr2'
Variable 'MarketName' is created at the Server/App level
Variable 'MarketName' is created at the Server level
--> No Errors in EssCreateVariable
関連トピック