In the following example, all the errors are reported in a loop.
int iErrAreaLen;
short sErrCnt = 0;
short i = 0;
#ifndef USE_ODPP_MBCS_CHAR_CALLS
#else
#endif
if(ODPPSUCCESS != retVal)
{
printf("Failed to get the Error Count, Err=%#x", retVal);
return retVal;
}
if(sErrCnt <= 0)
{
printf("\nNo Error Detected\n");
return ODPPSUCCESS;
}
printf("\nTotal Error Count = %d\n", sErrCnt);
pEcb = (
DP_ECB*)malloc(iErrAreaLen);
if(NULL == pEcb)
{
printf("Error Block Malloc failed\n");
goto OnErrorClean;
}
memset(pEcb, 0, iErrAreaLen);
#ifndef USE_ODPP_MBCS_CHAR_CALLS
if(NULL == ErrMsg.EM.
pWC)
{
printf("\nMem Alloc failed for DPEM_WC_SS \n");
goto OnErrorClean;
}
ErrMsg.EM.
pWC->
pMsg = &ErrMsgText[0];
#else
if(NULL == ErrMsg.EM.
pMC)
{
printf("\nMem Alloc failed for DPEM_MC_SS \n");
goto OnErrorClean;
}
ErrMsg.EM.
pMC->
pMsg = &ErrMsgText[0];
#endif
for ( short i = 0; i < sErrCnt; i++ )
{
printf(
"\nRow Number: %d\n",(
int)pEcb->
iRowNum);
printf(
"Error Code: %d\t",pEcb->
iErrCode);
memset(ErrMsgSrc,'\0',sizeof(ErrMsgSrc));
memset(ErrMsgText,'\0',sizeof(ErrMsgText));
memset(ErrMsgBody,'\0',sizeof(ErrMsgBody));
if(retVal != ODPPSUCCESS)
{
printf("Error Code not found, Err = %#x\n",retVal);
continue;
}
#ifndef USE_ODPP_MBCS_CHAR_CALLS
printf("Error Message Source:%ws\n",ErrMsgSrc);
printf("Error Message Text: %ws \n",ErrMsgText);
printf("Error Message Body: \n%ws\n",ErrMsgBody);
#else
printf("Error Message Source:%s\n",ErrMsgSrc);
printf("Error Message Text: %s \n",ErrMsgText);
printf("Error Message Body: \n %s\n",ErrMsgBody);
#endif
}
if(retVal != ODPPSUCCESS)
{
printf("Provider_TermErrors failed, Err = %#x\n",retVal);
return retVal;
}
Free the memory allocated.