EssCreateVariable

 

代替変数を新規作成、または同一のサーバー値、アプリケーション値およびデータベース値を持つ変数名がすでに存在している場合には既存の代替変数を変更します。

構文

            ESS_FUNC_M EssCreateVariable (
            hCtx, pVariable
            );
         
パラメータデータ型説明

hCtx

ESS_HCTX_T

APIコンテキスト・ハンドル。

pVariable

ESS_PVARIABLE_T

作成された代替変数の説明を含む構造体を指すポインタ。

備考

戻り値

成功の場合、ゼロが戻されます。

         /*
** 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
      

関連トピック