# EssListDatabases

Description

EssListDatabases() lists all databases which are accessible to the caller, either within a specific application, or on an entire server.

Syntax

    ESS_FUNC_M EssListDatabases (hCtx, AppName, pCount, ppDbList);

ESS_HCTX_T | hCtx
ESS_STR_T | AppName
ESS_PUSHORT_T | pCount
ESS_PPAPPDB_T | ppDbList

Parameters

hCtx | Essbase API context handle
AppName | Application name
pCount | Address of variable to receive count of applications and databases
ppDbList | Address of pointer to receive allocated array of application/databasename structures

Return Value

If successful, this function returns a count of the number of accessible databases in pCount, and a list of the application and database names in ppDbList.

Notes

- If the AppName argument is NULL, this function lists all the accessible applications and databases on the server.
- The ppDbList argument returns an array of structures containing matching pairs of application and databasename strings.
- The memory allocated for ppDbList must be freed using EssFree().

Access

This function requires no special privileges; note however that server databases will only be listed if the caller has access to them.

Example

    ESS_FUNC_M
    ESS_ListDbs (ESS_HCTX_T  hCtx,
                ESS_HINST_T hInst
               )
    {
       ESS_FUNC_M     sts = ESS_STS_NOERR;
       ESS_USHORT_T  Items;
       ESS_USHORT_T  ind;
       ESS_PAPPDB_T  pAppsDbs = NULL;
       sts = EssListDatabases (hCtx, NULL, &Items,
             &pAppsDbs);
       if (!sts)
       {
          if (Items && pAppsDbs)
          {
    printf ("\r\n-----Applications/databases available-----\r\n");
             for (ind = 0; ind < Items; ind++)
             {
                if ((pAppsDbs+ind) != NULL)
                 {
                  if ((pAppsDbs[ind].AppName != NULL) &&
                        (pAppsDbs[ind].DbName  != NULL))
                    {
    printf ("%s", pAppsDbs[ind].AppName);
    printf (" ==> ");
    printf ("%s", pAppsDbs[ind].DbName);
    printf ("\n\r");
                    }
                 }
             }
             EssFree (hInst, pAppsDbs);
          }
          else
    printf ("\r\ndatabaseList is Empty\r\n\r\n");
       }

       return(sts);
    }

See Also

EssGetDatabaseInfo()
EssGetDatabaseState()
EssListApplications()
EssListCurrencyDatabases()
EssListObjects()