# EssListDbFiles

Description

EssListDbFiles() retrieves information on specified index and data files.

Syntax

ESS_FUNC_M EssListDbFiles (hCtx, szAppName, szDbName, usFileType, pNmbrOfFiles, ppInfoArray);

ESS_HCTX_T | hCtx;
ESS_STR_T | szAppName;
ESS_STR_T | szDbName;
ESS_USHORT_T | usFileType;
ESS_PUSHORT_T | pNmbrOfFiles;
ESS_PPDBFILEINFO_T | ppDbInfoArray;

Parameters

hCtx | Context handle
szAppName | Application name
szDbName | Database name
usFileType | One of the following file types to be returned: ESS_FILETYPE_INDEX ESS_FILETYPE_DATA ESS_FILETYPE_INDEX | ESS_FILETYPE_DATA
pNmbrOfFiles | Pointer to the number of index and data files returned
ppDbInfoArray | Pointer to an array of database file information structures returned

Return Value

If successful,
- EssListDbFiles() returns 0
- pNmbrOfFiles contains a pointer to the number of index and data files returned
- ppDbInfoArray contains a pointer to an array of database file information structures returned

Notes

Access

Example

    ESS_STS_T ListDbFiles( ESS_HCTX_T hCtx )
    {
       ESS_STS_T         sts         = ESS_STS_NOERR;
       ESS_APPNAME_T     pszAppName;
       ESS_DBNAME_T      pszDbName;
       ESS_PDBFILEINFO_T aDbFileInfo = NULL;
       ESS_PDBFILEINFO_T pDbFileInfo = NULL;
       ESS_USHORT_T      usFileType  = ( ESS_FILETYPE_INDEX | ESS_FILETYPE_DATA );
       ESS_USHORT_T      usFileCount = 0;
       ESS_USHORT_T      usFileIx;

       /**************************************************************
        * Prompt for the type of files to list: index, data or both, *
        * and assign the user's file type choice to usFileType       *
        **************************************************************
        * This function uses ESS_FILETYPE_INDEX | ESS_FILETYPE_DATA  *
        * as the default value                                       *
        **************************************************************/
                                     .
                                     .
                                     .

       /*************************************************************
        * Prompt for application and database names, and assign the *
        * user's choices to pszAppName and pszDbName, respectively  *
        *************************************************************/
                                     .
                                     .
                                     .

       /*********************************************************************
        * Get an array of persistent database file information from Essbase *
        * for the selected file type, application and database              *
        *********************************************************************/
       sts = EssListDbFiles( hCtx, pszAppName, pszDbName, usFileType,
                             &usFileCount, &aDbFileInfo );
       if ( sts )
       {
          goto exit;
       }

       /**********************************************
        * Format and display the information in the  *
        * persistent database file information array *
        **********************************************/
       if ( ( usFileCount ) && ( aDbFileInfo ) )
       {
          printf( "Application Name:      %s\n",
                  aDbFileInfo[ 0 ].AppName );

          printf( "Database Name:         %s\n",
                  aDbFileInfo[ 0 ].DbName  );

          for ( ( usFileIx = 0, usFileType = 0 );
                usFileIx < usFileCount;
                usFileIx++ )
          {
             /******************************************************
              * Format and display the information in the current  *
              * persistent database file information array element *
              ******************************************************/
             pDbFileInfo = &( aDbFileInfo[ usFileIx ] );

             printf( "\nFile %lu:\n",
                     pDbFileInfo->FileSequenceNum );

             printf( "   File Name:          %s\n",
                     pDbFileInfo->FilePath );

             printf( "   File Type:          " );

    		 if ( pDbFileInfo->FileType == ESS_FILETYPE_INDEX )
             {
                printf( "INDEX\n" );
             }
             else
             {
                printf( "DATA\n" );
             }

             printf( "   File Number:        %lu of %lu\n",
                      pDbFileInfo->FileSequenceNum, pDbFileInfo->FileCount );

             printf( "   File Size:          %lu\n",
                     pDbFileInfo->FileSize );

             printf( "   File Opened:        %c\n",
                      ( pDbFileInfo->FileOpen ) ? 'Y' : 'N' );
          }  /* FOR usFileIx */

          /************************************************
           * Free the memory allocated for the persistent *
           * database file information array              *
           ************************************************/
          free( aDbFileInfo );
       }

       else
       {
          printf( "Application Name:      %s\n",
                  AppName );

          printf( "Database Name:         %s\n",
                  DbName  );

          switch ( usFileType )
          {
          case ESS_FILETYPE_INDEX:
             printf( "\nNo existing INDEX files.\n" );
             break;
          case ESS_FILETYPE_DATA:
             printf( "\nNo existing DATA files.\n" );
             break;
          case ( ESS_FILETYPE_INDEX | ESS_FILETYPE_DATA ):
             printf( "\nNo existing INDEX or DATA files.\n" );
             break;
          default:
             printf( "\nNo existing database files of the selected type.\n" );
             break;
          }  /* SWITCH usFileType */
       }

       printf( "\n" );

    exit:

       return ( sts );
    }

See Also

ESS_DBFILEINFO_T