ttUtilGetError

Description

Retrieves the errors and warnings generated by the last call to the TimesTen C utility library functions excluding ttUtilAllocEnv and ttUtilFreeEnv.

Required Privilege

None

Syntax

ttUtilGetError (ttUtilHandle handle, unsigned int errIndex,
                unsigned int* retCode, ttUtilErrType* retType,
                char* errbuff, unsigned int buffLen,
                unsigned int* errLen)

Parameters

Parameter Type Description

handle

ttUtilHandle

Specifies the TimesTen utility library environment handle allocated using ttUtilAllocEnv.

errIndex

unsigned int

Indicates error or warning record to be retrieved from the TimesTen utility library error array. Valid values are as follows:

  • 0: Retrieve the next record from the utility library error array.

  • 1...n: Retrieve the specified record from the utility library error array, where n is the error count returned by the ttUtilGetErrorCount call.

retCode

unsigned int*

Returns the TimesTen-specific error or warning codes as defined in tt_errCode.h.

retType

ttUtilErrType*

Indicates whether the returned message is an error or warning. The following are valid return values:

  • TTUTIL_ERROR

  • TTUTIL_WARNING

errBuff

char*

This is a user allocated buffer where error messages (if any) are to be returned. The returned error message is a null-terminated string. If the length of the error message exceeds buffLen-1, it is truncated to buffLen-1. If this parameter is NULL, buffLen is ignored and TimesTen does not return error messages to the calling application.

buffLen

unsigned int

Specifies the size of the buffer errBuff. If this parameter is 0, TimesTen does not return error messages to the calling application.

errLen

unsigned int*

A pointer to an unsigned integer where the actual length of the error message is returned. If it is NULL, TimesTen ignores this parameter.

Return Codes

This utility returns the following codes as defined in ttutillib.h.

Code Description

TTUTIL_SUCCESS

Returned upon success.

TTUTIL_INVALID_HANDLE

Returned if an invalid utility library handle is specified.

TTUTIL_NODATA

Returned if no error or warming information is retrieved.

Example

This example retrieves all error or warning information after calling ttDestroyDataStore for the DSN named payroll.

char            errBuff[256];
int             rc;
unsigned int    retCode;
ttUtilErrType   retType;
ttUtilHandle    utilHandle;

rc = ttDestroyDataStore (utilHandle, "DSN=PAYROLL", 30);
if ((rc == TTUTIL_SUCCESS) 
  printf ("Datastore payroll successfully destroyed.\n");
else if (rc == TTUTIL_INVALID_HANDLE)
  printf ("TimesTen utility library handle is invalid.\n");
else
    while ((rc = ttUtilGetError (utilHandle, 0,
        &retCode, &retType, errBuff, sizeof (errBuff),
        NULL)) != TTUTIL_NODATA)
    {
...
...
}

Notes

Each of the TimesTen C functions can potentially generate multiple errors and warnings for a single call from an application. To retrieve all of these errors and warnings, the application must make repeated calls to ttUtilGetError until it returns TTUTIL_NODATA.