MQeFieldsGet

Description
Given a field name, retrieves the data type, length of field data and field data. This API is used to retrieve information about a field with a given name. The datatype is returned in the pointer. MQeFieldsGetByArrayOfFd should be used to get a field with a specific datatype.

Syntax
#include <hmq.h>
MQEINT32 MQeFieldsGet( MQEHSESS hSess, MQEHFIELDS hFlds, 
            MQECHAR * pName, MQEBYTE * pDataType, 
            MQEVOID * pData, MQEINT32 nElements, MQEVOID *pBase, 
            MQEINT32 * pCompCode, MQEINT32 * pReason) 

Parameters

MQEHSESS hSess - input
The session handle, returned by MQeInitialize.

MQEHFIELDS hFlds - input
The handle to an MQeFields object.

MQECHAR * pName - input
The null terminated string name of the field.

MQEBYTE * pDataType - input and output
The input value is used with nElements to specify the size of the data buffer. The output value is the type of the field.

MQEVOID * pData - input and output
The destination buffer to receive the copy of the field data. If this parameter is a NULL, then the number of the elements of datatype is returned.

If data type is MQE_TYPE_FIELDS, then a single field object handle MQEHFIELDS is returned.

If data type is MQE_TYPE_UNTYPED, then it is treated as an array of bytes.

MQEINT32 nElements - input
Specifies the size of the pData buffer in the number of elements of the input value of *pDataType. If pDataType is NULL, the default is MQE_TYPE_BYTE. If pData is NULL, then this parameter is ignored.

MQEVOID * pBase - input
A platform specific base pointer.

MQEINT32 * pCompCode - output
MQECC_OK, MQECC_WARNING or MQECC_ERROR.

MQEINT32 * pReason - output

Return Value

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

Example
#include <hmq.h>
static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields";
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds;
MQEBYTE  datatype;
MQEINT32  n;
MQEBYTE * pdata;
MQEBYTE * buf;
MQEINT32  rc;
 
hSess = MQeInitialize("MyAppsName", &compcode, &reason);
hFlds = MQeFieldsAlloc( hSess, FieldsType, &compcode, &reason);
 
/*
 * Add some fields to the fields object... and one of them is "XYZ"
 */
 ...
 
/* Get the field data length */
n = MQeFieldsGet( hSess, hFlds, "XYZ", &datatype, NULL, 0, NULL, 
         &compcode, &reason);
 
/* Verfify that datatype is correct. */
 
/* Get some space to put the data */
buf = (MQEBYTE *)calloc(n, MQE_SIZEOF(datatype));
 
/* Get the field data */
rc = MQeFieldsGet( hSess, hFlds, "XYZ", &datatype, &buf, n, NULL,
         &compcode, &reason);
 

See Also
MQeFieldsPut


© IBM Corporation 2002. All Rights Reserved