MQeFieldsGetAscii, MQeFieldsGetUnicode, MQeFieldsGetObject

Description
Extracts an array of MQECHAR, MQEINT16, or MQEBYTE from a single field in the MQeFields object. The extracted arrays are not terminated with an additional NULL, so if the field data is not terminated the extracted string is not. Returns the length of the field data (not the extracted string) as the number of elements (not bytes) or '-1' on error.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsGetAscii( MQEHSESS hSess, 
									MQEHFIELDS hFlds, 
              				MQECHAR* pName, MQEBYTE* pData, 
             					MQEINT32 DataLen, MQEINT32* 
              				pCompCode, MQEINT32* pReason) 
 
MQEINT32 MQeFieldsGetUnicode( MQEHSESS hSess, 
										MQEHFIELDS hFlds, 
               					MQECHAR* pName, MQEINT16 pData, 
              					MQEINT32 DataLen, 
               					MQEINT32* pCompCode, MQEINT32* pReason) 
 
MQEINT32 MQeFieldsGetObject( MQEHSESS hSess, 
										MQEHFIELDS hFlds, 
										MQECHAR* pName, 
               					MQEBYTE* pData, 
										MQEINT32 DataLen, 
               					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.

MQEBYTE * pData - output
The caller supplied destination buffer to receive the output data.

MQEINT16 * pData - output
The caller supplied destination buffer to receive the output data.

MQEINT32 DataLen - input
The maximum number of elements to copy

MQEINT32 * pCompCode - output
MQECC_OK, MQECC_WARNING or MQECC_ERROR.

MQEINT32 * pReason - output

Return Value

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

Example
#include <hmq.h>
#include <hmqHelper.h>
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
static const MQECHAR * textVal = 
			"The Owl and the Pussy Cat went to sea";
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds;
MQEINT32  n;
MQEBYTE  datatype;
MQEBYTE * pData;
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
								&compcode, 
								&reason);
hFlds  = MQeFieldsAlloc( hSess, FieldsType, 
									&compcode, &reason);
rc   = MQeFieldsPut( hSess, hFlds, "ibm", 
								MQE_TYPE_ASCII, 
								strlen(textVal)), 
            				textVal, 
								&compcode, 
								&reason); 
 
/* Get the data length */
n    = MQeFieldsDataLen( hSess, hFlds, "ibm", 
									&compcode, &reason);
 
datatype= MQE_TYPE_ASCII;
pData  = (MQEBYTE *) 
			calloc(n, MQE_SIZEOF(datatype));
 
/* Copy out the data */
rc   = MQeFieldsGetAscii( hSess, hFlds, "ibm", 
									pData, n, 
									&compcode, &reason);

See Also


© IBM Corporation 2002. All Rights Reserved