getBatchStatusCode

The getBatchStatusCode method returns the highest status code from the array of commands executed by the executeBatch method.

getBatchStatusCode()

Return value

The getBatchStatusCode method returns an integer.

  • 0 - STATUS_SUCCESS-The method called completed with no errors.
  • 1 - STATUS_WARNING-The method called completed with at least one warning (but no errors).
  • 2 - STATUS_ERROR-The method called did not complete successfully and has at least one error.

Example

The following code sample gives an example of how to retrieve the BatchStatusCode.


// Top level status code is a short cut to determine if there are any 
// non-successes in the array of Response objects
if(batchResponse.getBatchStatusCode() == Response.STATUS_SUCCESS)
{
  System.out.println("ExecuteBatch ran perfectly!");
}
else if(batchResponse.getBatchStatusCode() == Response.STATUS_WARNING)
{
  System.out.println("ExecuteBatch call processed with at least one warning");
}
else
{
  System.out.println("ExecuteBatch call processed with at least one error");
}
   
// Iterate through the array, and print out the message for any non-successes
for(Response response : batchResponse.getResponses())
{
  if(response.getStatusCode()!=Response.STATUS_SUCCESS)
  {
      printDetailMessageOfWarningOrError("executeBatchCommand",
			response.getAdvisoryMessages());
  }
}