# EssGetAttributeInfo

Description

This function returns attribute information for a given attribute member or dimension.

Syntax

ESS_FUNC_M EssGetAttributeInfo (hCtx, szAttributeName, pAttributeInfo);

ESS_HCTX_T | hCtx;
ESS_STR_T | szAttributeName;
ESS_PPATTRIBUTEINFO_T | pAttributeInfo;

Parameters

hCtx | Context handle
szAttributeName | Name of the attribute member or dimension
pAttributeInfo | Attribute information

Return Value

Notes

- After you call this function, call EssFreeStructure() to free memory dynamically allocated by EssGetAttributeInfo() for string type attribute information.

Access

This function requires no special privileges.

Example

    void  ESS_GetAttributeInfo()
    {
       ESS_STS_T             sts;
       ESS_PATTRIBUTEINFO_T  pAttributeInfo;
       ESS_CHAR_T            time_string[32];
       struct tm*            pTime;
       ESS_DATETIME_T        et;
       ESS_PATTRSPECS_T      pAttrSpecs;
       ESS_USHORT_T          usDateFormat;

       /* sts = EssGetAttributeInfo(hCtx, "ounces_12", &pAttributeInfo); */
       /* sts = EssGetAttributeInfo(hCtx, "ounces", &pAttributeInfo); */
       /* sts = EssGetAttributeInfo(hCtx, "caffeinated_true", &pAttributeInfo); */
       /* sts = EssGetAttributeInfo(hCtx, "caffeinated", &pAttributeInfo); */
       sts = EssGetAttributeInfo(hCtx, "intro date_10-01-1996", &pAttributeInfo);
       /* sts = EssGetAttributeInfo(hCtx, "intro date", &pAttributeInfo); */
       /* sts = EssGetAttributeInfo(hCtx, "can", &pAttributeInfo); */
       /* sts = EssGetAttributeInfo(hCtx, "pkg type", &pAttributeInfo); */

       if(sts)
          fprintf(stderr,"Error in EssGetAttributeInfo(): %ld", sts);

       /* for handling time values */
       et = pAttributeInfo->Attribute.value.dtData;
       printf("Member name: %s\n", pAttributeInfo->MbrName);
       printf("Dimension name: %s\n", pAttributeInfo->DimName);
       /* printf("Attribute: %s\n", pAttributeInfo->Attribute); */
       switch(pAttributeInfo->Attribute.usDataType)
        {
             case ESS_ATTRMBRDT_BOOL:
                printf ("Data Type    : Boolean \n");
                if ( pAttributeInfo->Attribute.value.bData)
                   printf ("Data Value   : True \n");
                else
                   printf ("Data Value   : False \n");
                break;

             case ESS_ATTRMBRDT_DOUBLE:
                printf ("Data Type    : Numeric(Double) \n");
                printf ("Data Value   : %g \n",pAttributeInfo->Attribute.value.dblData);
                break;
             case ESS_ATTRMBRDT_DATETIME:
                printf ("Data Type    : Date \n");
             sts = EssGetAttributeSpecifications(hCtx, &pAttrSpecs);
                if (sts)
                usDateFormat = ESS_DATEFORMAT_MMDDYYYY;
                else
                usDateFormat = pAttrSpecs->usDateFormat;

                pTime =  gmtime((time_t*)&et);
                switch(usDateFormat)
                {
                case ESS_DATEFORMAT_MMDDYYYY:
                   sprintf(time_string, "MM-DD-YYYY %02i-%02i-%04i",
                      pTime->tm_mon+1, pTime->tm_mday,pTime->tm_year+1900);
                   break;
                case ESS_DATEFORMAT_DDMMYYYY :
                   sprintf(time_string, "DD-MM-YYYY %02i-%02i-%04i",
                      pTime->tm_mday,pTime->tm_mon+1, pTime->tm_year+1900);
                   break;
                }
                printf ("Data Value   : %s \n", time_string);
                break;
             case ESS_ATTRMBRDT_STRING:
                printf ("Data Type    : String \n");
                printf ("Data Value   : %s \n", pAttributeInfo->Attribute.value.strData);
                EssFree(hInst, pAttributeInfo->Attribute.value.strData);
                break;
             }
       EssFreeStructure(hInst, ESS_DT_STRUCT_ATTRIBUTEINFO, 1, pAttributeInfo);
    }

See Also

EssCheckAttributes()
EssFreeStructure()
EssGetAssociatedAttributesInfo()
EssGetAttributeSpecifications()
EssOtlAssociateAttributeDimension()
EssOtlAssociateAttributeMember()
EssOtlDisassociateAttributeDimension()
EssOtlDisassociateAttributeMember()
EssOtlFindAttributeMembers()
EssOtlFreeStructure()
EssOtlGetAssociatedAttributes()
EssOtlGetAttributeInfo()
EssOtlGetAttributeSpecifications()
EssOtlQueryAttributes()
EssOtlSetAttributeSpecifications()