# EssListRequests

Description

EssListRequests() returns information about sessions and requests in progress, terminated, or in the process of being terminated.

Syntax

    ESS_FUNC_M EssListRequests (hCtx, UserName, AppName, DbName, RequestCount, pRequestInfo);

ESS_HCTX_T | hCtx
ESS_STR_T | UserName
ESS_STR_T | AppName
ESS_STR_T | DbName
ESS_PUSHORT_T | RequestCount
ESS_PPREQUESTINFO_T | ppRequestInfoStruct

Parameters

hCtx | Essbase API context handle.
pDdbCtx | Distributed database context to be filled.

Return Value

Returns zero if successful; error code if unsuccessful.

Notes

EssListRequests() returns information about sessions and requests in progress, terminated, or in the process of being terminated.

A session is the time in seconds between an Essbase user's login and logout.

A request is a query sent to Essbase by a user or by another process; for example, starting an application, or restructuring a database outline. Each session can process only one request at a time; therefore, sessions and requests have a one-to-one relationship.

This function returns information on requests/sessions initiated by the process specified by the UserName, AppName, and DbName. If these parameters are null or empty, then all the processes in the system are listed. This function returns the number of current, terminating, and terminated requests and one ESS_REQUESTINFO_T structure for each request.

The returned ppRequestInfoStruct needs to be freed by calling EssFree.

Example

    #include
    #include

    ESS_FUNC_M ESS_ListRequest ()
    {
        ESS_FUNC_M       sts     = ESS_STS_NOERR;
        ESS_STR_T     rString = NULL;
        ESS_HCTX_T   hCtx;
        ESS_USHORT_T Items;
        ESS_PAPPDB_T pAppsDbs = NULL;
        ESS_HINST_T  hInst ;
        ESS_ACCESS_T Access;
        ESS_USHORT_T numRequest;
        ESS_PREQUESTINFO_T requestInfo;

        ESS_INIT_T InitStruct =        /* Define init */
                        /* structure */
        {
            ESS_API_VERSION,       /* Version of API */
            NULL,      /* user-defined message context */
            0,         /* max handles     */
            0L,        /* max buffer size */
            NULL, /* local path */
            /* The following parameters use defaults  */
            NULL,      /* message db path */
            NULL,      /* allocation function pointer */
            NULL,      /* reallocation function pointer */
            NULL,      /* free function pointer */
            NULL,   /* error handling function pointer */
            NULL,      /* path name of user-defined */
                   /* Application help file */
            NULL,      /* Reserved for internal use. */
                   /* Set to NULL */
        };

        EssInit (&InitStruct, &hInst);

        sts = EssLogin (hInst, "local", "admin", "password", &Items, &pAppsDbs, &hCtx);

        sts = EssSetActive ( hCtx, "sample", "basic", &Access );

        sts = EssListRequests( hCtx, NULL, NULL, NULL, &numRequest, &requestInfo);

        printf ( "Total requests on the server %d\n", numRequest );

        if ( !sts && requestInfo )
        {
            ESS_USHORT_T index = 0;

            while ( index < numRequest )
            {
                printf ( "login ID = %ul\n", requestInfo[index].LoginId );
                printf ( "user name = %s\n", requestInfo[index].UserName );
                printf ( "login machine = %s\n", requestInfo[index].LoginSourceMachine );
                printf ( "AppName = %s\n", requestInfo[index].AppName );
                printf ( "DbName = %s\n", requestInfo[index].DbName );
                printf ( "DbRequestCode = %u\n", requestInfo[index].DbRequestCode );
                printf ( "RequestString = %s\n", requestInfo[index].RequestString );
                printf ( "TimeStarted = %ul\n", requestInfo[index].TimeStarted );
                printf ( "State = %d\n", requestInfo[index].State );
                printf ( "\n\n--------------------------------------\n\n", requestInfo[index].State );

                sts = EssKillRequest (hCtx, &requestInfo[index] );

                index++;
            }

            EssFree ( hInst, requestInfo );
        }

        EssLogout (hCtx);
        EssTerm (hInst);
        return(sts);
    }

    void main()
    {
        ESS_ListRequest ();
    }

See Also

EssKillRequest
ESS_REQUESTINFO_T
ESS_REQ_STATE_T