MQeFieldsGetAsciiArray, MQeFieldsGetUnicodeArray, MQeFieldsGetByteArray

Description
Extracts an encoded two dimensional array of MQECHAR, MQESHORT, or MQEBYTE. Starting at source index srcOff. Extract at most n arrays, into each of the buffers provided by ppData. The input values in pDataLen indicate the size of the buffer. The output values indicate the size of the corresponding string in the field, or '-1' if an error occurred for the string at the corresponding index. Both ppStr and pDataLen start at base '0' regardless of the value of srcOff .

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsGetAsciiArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQECHAR * ppData[], 
                 MQEINT32 pDataLen[], MQEINT32 srcOff, 
                 MQEINT32 n, MQEINT32 * pCompCode, 
                 MQEINT32 * pReason) 
MQEINT32 MQeFieldsGetUnicodeArray( MQEHSESS hSess, MQEHFIELDS hFlds,
                  MQECHAR * pName, MQEINT16 * ppData[], 
                  MQEINT32 pDataLen[], MQEINT32 srcOff, 
                  MQEINT32 n, MQEINT32 * pCompCode, 
                  MQEINT32 * pReason) 
MQEINT32 MQeFieldsGetByteArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                MQECHAR * pName, MQEBYTE * ppData[], 
                MQEINT32 pDataLen[], 
                MQEINT32 srcOff, MQEINT32 n, 
                MQEINT32 * pCompCode, MQEINT32 * pReason)

Parameters

MQEHSESS hSess - input
The session handle, returned by MQeInitialize.

MQEHFIELDS hFlds - input
A handle to an MQeFields object.

MQECHAR * pName - input
A null terminated string containing the name of the field. A null or a zero length string is invalid.

MQECHAR * ppData[] - output
Array of n buffers, starting at index '0'. If any buffer is NULL, then data is not extracted for that buffer. If NULL, then all buffers are treated as NULL.

MQEINT16 * ppData[] - output
Array of n buffers, starting at index '0'. If any buffer is NULL, then data is not extracted for that buffer. If NULL, then all buffers are treated as NULL.

MQEBYTE * ppData[] - output
Array of n buffers, starting at index '0'. If any buffer is NULL, then data is not extracted for that buffer. If NULL, then all buffers are treated as NULL.

MQEINT32 pDataLen[] - input and output
Array of n buffer lengths. The input values specify the length of the buffer in MQECHAR. The output values specify the length of the array element in the MQeFields object in MQECHAR. If NULL, then all buffer lengths are considered to be '0'.

MQEINT32 srcOff - input
The starting source index from which to copy the array elements.

MQEINT32 n - input
The number of elements to get. If '0', the number of elements in the field is returned.

MQEINT32 * pCompCode - output
MQECC_OK, MQECC_WARNING or MQECC_ERROR.

MQEINT32 * pReason - output
If the returned *pCompCode equals MQECC_ERROR, *pReason may have any of the following values:

MQE_EXCEPT_NOT_FOUND
A field was not found.

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_ALLOCATION_FAILED

MQE_EXCEPT_TYPE
The data type of an array element does not match the type of the initial source array element, or the number of array elements encoded in hFlds is invalid.

MQE_EXCEPT_DATA
The field containing the size of the array contains an invalid value.

MQE_EXCEPT_INVALID_ARGUMENT
scrOff is less than '0' or greater than or equal to the number of elements in the source array.

Return Value

MQEINT32
  • On success, returns the number of in the encoded array.
  • On failure, returns a count of the number of elements processed in the array including the failing element.
  • If an error occurs prior to any elements being processed, '-1' is returned.

Example
#include <hmq.h>
#include <hmqHelper.h>
static MQECHAR const * FieldsType = 
		"com.ibm.mqe.MQeFields";
static const MQECHAR * textArray[] = 
        { "The Owl and the Pussy Cat went to sea",
         "Here we go round the Mulberry bush",
         "Jack and Jill went up the hill" };
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds;
MQEINT32  pStrLen[3], n, *pStrLen2;
MQEBYTE * pData;
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
									&compcode, &reason);
hFlds  = MQeFieldsAlloc( hSess, FieldsType, 
									&compcode, &reason);
 
pStrLen[0] = strlen(textArray[0]);
pStrLen[1] = strlen(textArray[1]);
pStrLen[2] = strlen(textArray[2]);
rc = MQeFieldsPutAsciiArray( hSess, hFlds, "ibm", 
										textArray, pStrLen, 3, 
              					&compcode, &reason); 
 
/* 1. Get number of elements */
n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", 
										NULL, NULL, 0, 0, 
              					&compcode, &reason);
 
/* Get space for array of string length */
pStrLen2 = (MQEINT32 *) 
				malloc(n * sizeof(MQEINT32));
memset(pStrLen2, 0, n * sizeof(MQEINT32));
 
/* 2. Get array of string length */
n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", 
										NULL, pStrLen2, 0, n, 
              					&compcode, &reason);
 
/* Get space for array of string */
for (i=0; i<n; i++) {
  pStr[i] = (MQECHAR *) 
								malloc(pStrLen[j]+1);
  memset(pStr[i], 0, 
			pStrLen[j]+1);
}
 
/* 2. Get array of strings */
n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", 
										pStr, pStrLen2, 0, n, 
              					&compcode, &reason);
 

See Also


© IBM Corporation 2002. All Rights Reserved