MQeFieldsGetShortArray, MQeFieldsGetIntArray, MQeFieldsGetLongArray, MQeFieldsGetFloatArray, MQeFieldsGetDoubleArray

Description
Extracts an encoded array from the MQeFields object as an array of 2, 4, or 8-byte integers, floats, or doubles.

Returns the number of elements successfully extracted, or '-1' on an error.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsGetShortArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQEINT16 * pData, 
                 MQEINT32 srcOff, MQEINT32 n, 
                 MQEINT32 * pCompCode, MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsGetIntArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                MQECHAR * pName, MQEINT32 * pData, 
                MQEINT32 srcOff, MQEINT32 n, 
                MQEINT32 * pCompCode, MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsGetLongArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                MQECHAR * pName, MQEINT64 * pData, 
                MQEINT32 srcOff, MQEINT32 n, 
                MQEINT32 * pCompCode, MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsGetFloatArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQEFLOAT * pData, 
                 MQEINT32 srcOff, MQEINT32 n, 
                 MQEINT32 * pCompCode, MQEINT32 * pReason) 
 
MQEINT32 MQeFieldsGetDoubleArray( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQECHAR * pName, MQEDOUBLE * pData, 
                 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 name of the field. A null or a zero length string is invalid.

MQEINT16 * pData - output
The returned short value.

MQEINT32 * pData - output
The returned 4 byte integer value.

MQEINT64 * pData - output
The returned 8 byte integer value.

MQEFLOAT * pData - output
The returned double value.

MQEDOUBLE * pData - output
The returned float value.

MQEINT32 srcOff - input
The starting index for source array.

MQEINT32 n - input
The number of elements to get.

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_DATA
srcOff is out of range, or invalid array encoding.

MQE_EXCEPT_TYPE
Field element does not match requested type.

MQE_EXCEPT_INVALID_HANDLE

Return Value

MQEINT32
  • On success, returns the number of elements in the source array.
  • On failure, returns a count of the number of elements processed in the source 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";
MQEHSESS   hSess;
MQEINT32   compcode;
MQEINT32   reason;
MQEHFIELDS hFlds;
MQEINT16   shorts[2];
MQEINT16*  gotShorts;
MQEINT32   ints[3];
MQEINT32*  gotInts;
MQEINT64   longs[2];
MQEINT64*  gotLongs;
MQEINT32   rc;
MQEINT32   length;
#define NULL 0
 
hSess    = MQeInitialize("MyAppsName", 
									&compcode, &reason);
hFlds    = MQeFieldsAlloc( hSess, FieldsType, 
										&compcode, &reason);
 
shorts[0]= 32000;
shorts[1]= 32020;
MQeFieldsPutArray( hSess, hFlds, "sh", 
							MQE_TYPE_SHORT, 
							&shorts[0], 2, 
							&compcode, 
							&reason); 
ints[0]  = 2000100000;
ints[1]  = 2000020000;
ints[2]  = 2000003000;
MQeFieldsPutArray( hSess, hFlds, "int", 
							MQE_TYPE_INT, 
							&ints[0], 3, 
							&compcode, 
							&reason); 
longs[0].hi = 265;
longs[0].lo = 2000000000;
longs[1].hi = 2000000000;
longs[1].lo = 255;
MQeFieldsPutArray( hSess, hFlds, "lg", 
							MQE_TYPE_LONG, 
							&longs[0], 2, 
							&compcode, 
							&reason); 
 
/* Get the data */
length = MQeFieldsGetShortArray ( hSess, hFlds, "sh", 
												NULL, 0, 0, 
												&compcode, 
												&reason );
gotShorts = malloc(length * MQE_SIZEOF
							( MQE_TYPE_SHORT ));
MQeFieldsGetShortArray ( hSess, hFlds, "sh", 
									gotShorts, 0, 
									length, 
									&compcode, 
									&reason );
 
length = MQeFieldsGetIntArray   ( hSess, hFlds, "int", 
												NULL, 0, 0, 
												&compcode, 
												&reason );
gotInts = malloc(length * MQE_SIZEOF
							( MQE_TYPE_INT ));
MQeFieldsGetIntArray   ( hSess, hFlds, "int", 
									gotInts, 0, 
									length, 
									&compcode, 
									&reason );
 
length = MQeFieldsGetLongArray  ( hSess, hFlds, "lg", 
												NULL, 0, NULL, 
												&compcode, 
												&reason );
gotLongs = malloc(length * MQE_SIZEOF
								( MQE_TYPE_LONG ));
MQeFieldsGetLongArray  ( hSess, hFlds, "lg", 
									gotLongs, 0, 
									length, 
									&compcode, 
									&reason );

See Also


© IBM Corporation 2002. All Rights Reserved