MQeFieldsPutAsciiArray, MQeFieldsPutUnicodeArray, MQeFieldsPutByteArray

Description
Puts a 2 dimensional array of MQEINT16, MQECHAR, or MQEBYTE as an encoded array into an MQeFields object. The array elements are inserted in order as encoded fields, followed by the array length. Returns the total number of fields added to the MQeFields object.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsPutAsciiArray( MQEHSESS hSess, 
						MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQECHAR * ppData[], 
                 MQEINT32 pDataLen[], 
						MQEINT32 srcOff, 
                 MQEINT32 n, MQEINT32 * pCompCode, 
                 MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsPutUnicodeArray( MQEHSESS hSess, 
							MQEHFIELDS hFlds, 
                 	MQECHAR * pName, MQEINT16 * ppData[], 
                 	MQEINT32 pDataLen[], 
							MQEINT32 srcOff, 
                  	MQEINT32 n, MQEINT32 * pCompCode, 
                  	MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsPutByteArray( 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.

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

MQECHAR * ppData[] - input
An array of MQECHAR arrays.

MQEINT16 * ppData[] - input
An array of MQESHORT arrays.

MQEBYTE * ppData[] - input
An array of MQEBYTE.

MQEINT32 pDataLen[] - input
An array of lengths of each data element, corresponding to each element of ppData[] .

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

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_INVALID_HANDLE

MQE_EXCEPT_INVALID_ARGUMENT

MQE_EXCEPT_ALLOCATION_FAILED

Return Value

MQEINT32
  • On success, returns the number of fields successfully put.
  • On failure, returns a count of the number of fields processed including the failing field.
  • If an error occurs prior to any fields being processed, '-1' is returned.

Example
#include <hmq.h>
#include <hmqHelper.h>
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
static const char * 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);
}
 
/* 3. Get array of strings */
n = MQeFieldsGetAsciiArray( hSess, hFlds, 
										"ibm", pStr, 
										pStrLen2, 0, n, 
              					&compcode, &reason);
 

See Also


© IBM Corporation 2002. All Rights Reserved