MQeFieldsGetArrayLength

Description
Gets the number of elements in an encoded array. Returns the number of elements, or '-1' on error.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsGetArrayLength( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, 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 * 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
Field name not found.

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_TYPE
The field is not an encoded array.

MQE_EXCEPT_DATA
The field is not a valid encoded array.

Return Value

MQEINT32
  • On success, returns the number of elements in the encoded array.
  • On failure, returns '-1'.

Example
#include <hmq.h>
#include <:hmqHelper.h>
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
MQEHSESS   hSess;
MQEINT32   compcode;
MQEINT32   reason;
MQEHFIELDS hFlds;
MQEBYTE    datatype;
MQEINT32   data[2], n;
MQEINT32 * pData;
MQEINT32   rc;
 
 
hSess   = MQeInitialize("MyAppsName", 
									&compcode, 
									&reason);
hFlds   = MQeFieldsAlloc( hSess, 
										FieldsType, 
										&compcode, 
										&reason);
data[0] = 0x12345678;
data[1] = 0xDEADBEEF;
rc      = MQeFieldsPutIntArray(hSess, hFlds, 
											"foo", data, 2, 
											&compcode, 
											&reason); 
 
/* Get the data length */
n 		= MQeFieldsGetArrayLength( hSess, 
												hFlds, 
												"foo", 
												&compcode, 
												&reason );
 
datatype= MQE_TYPE_INT;
pData   = malloc(n * MQE_SIZEOF(datatype));
 
/* Copy out the data */
rc      = MQeFieldsGetIntArray( hSess, 
												hFlds, 
												"foo", 
												pData, 0, n, 
												&compcode, 
												&reason );
 

See Also
MQeFieldsPutArrayLength


© IBM Corporation 2002. All Rights Reserved