MQeFieldsPutArrayLength

Description
Puts the number of elements in an encoded array.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsPutArrayLength( 
						MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQEINT32 nElements, 
                 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 nElements - input
The number of array elements

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

Return Value

MQEINT32
Returns '0' on success, or '-1' on failure.

Example
#include <hmq.h>
#include <hmqHelper.h>
 
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
MQEHSESS   hSess;
MQEINT32   compcode;
MQEINT32   reason;
MQEHFIELDS hFlds;
MQEINT32   n, data0, data1;
MQEINT32 * pData;
MQEINT32   rc;
 
hSess   = MQeInitialize("MyAppsName", 
				&compcode, &reason);
hFlds   = MQeFieldsAlloc( hSess, FieldsType, 
				&compcode, &reason);
 
/* Manual construction of an 
/*integer array (vector) with two elements) */
data0 = 0x12345678;
data1 = 0xBEEFDEAD;
MQeFieldsPut( hSess, hFlds, "foo:0", 
					MQE_TYPE_INT, 
					&data0, 1, 
					&compcode, 
					&reason); 
MQeFieldsPut( hSess, hFlds, "foo:1", 
					MQE_TYPE_INT, 
					&data1, 1, 
					&compcode, 
					&reason); 
MQeFieldsPutArrayLength( hSess, hFlds, 
									"foo", 2, 	
									&compcode, 
									&reason); 
 
/* Get the data length */
n       = MQeFieldsGetArrayLength( hSess, hFlds, "foo", 
												&compcode, 
												&reason );
 
pData   = malloc(n * MQE_SIZEOF
						(MQE_TYPE_INT));
 
/* Get back the data */
rc      = MQeFieldsGetIntArray( hSess, hFlds, "foo", 
												pData, 0, n, 
												&compcode, &reason );

See Also
MQeFieldsGetArrayLength


© IBM Corporation 2002. All Rights Reserved