MQeFieldsGetByArrayOfFd

Description
Get fields data and data lengths from an MQeFields object for the names specified in the array of field descriptors. For each descriptor, both the field name and datatype must match to be successful.

Syntax
#include <hmq.h>
MQEINT32 MQeFieldsGetByArrayOfFd( MQEHSESS hSess, MQEHFIELDS hFlds, 
                 MQEFIELD pFds[], MQEINT32 nFds, 
                 MQEINT32 * pCompCode, MQEINT32 * pReason) 

Parameters

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

MQEHFIELDS hFlds - input
The handle to an MQeFields object.

(MQEFIELD *) pFds - input/output
An array of MQeField_st data structures. For each descriptor, the size destination buffer is determined by the input values of fd_datatype and fd_datalen. For successful descriptors, the output value of fd_datalen is set to the number of elements (not bytes) of the specified field.

The length of a field name is determined from the fd_name field, the fd_namelen field is ignored.

MQEINT32 nFds - input
Number of fields in the pFds array.

MQEINT32 * pCompCode - output
MQECC_OK, MQECC_WARNING or MQECC_ERROR. The error for the corresponding index to fail.

MQEINT32 * pReason - output
If the returned *pCompCode equals MQECC_ERROR, *pReason may have any of the following values:

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_ALLOCATION_FAILED

MQE_EXCEPT_TYPE
The field for a descriptor did not match the datatype.

MQE_EXCEPT_NOT_FOUND
No field was found for a descriptor.

Return Value

MQEINT32
  • On success, returns the number of descriptors successfully updated .
  • On failure, returns a count of the number of descriptors processed, including the failing descriptor.
  • If an error occurs prior to any descriptors being processed, '-1' is returned.

Example
#include <hmq.h>
static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields";
static const MQECHAR textVal[] = 
							"The Owl and the Pussy Cat went to sea.";
 
/* template for fields */
static const MQEFIELD PFDS[] = {
    {MQE_TYPE_BYTE, 0, 7, "fooByte", 
				(MQEBYTE *)0, 0, (MQEBYTE *)0},  
    {MQE_TYPE_SHORT, 0, 8, "fooShort", 
				(MQEBYTE *)0, 0, (MQEBYTE *)0},  
    {MQE_TYPE_LONG, 0, 7, "fooLong", 
				(MQEBYTE *)0, 0, (MQEBYTE *)0},  
    {MQE_TYPE_ASCII, 0, 7, "fooText", 
				(MQEBYTE *)0, 0, (MQEBYTE *)0}, 
    };
#define NFDS (sizeof(PFDS)/sizeof(PFDS[0]))
MQEHSESS  hSess;
MQEINT32  compcode;
MQEFIELD  Fds[NFDS];
MQEINT32  reason;
MQEHFIELDS hFlds;
MQEBYTE  byteVal;
MQEINT16  int16Val;
MQEINT32  int32Val;
MQEBYTE  datatype;
MQEINT32  rc;
MQEINT32  nFlds,i;
 
hSess = MQeInitialize("MyAppsName", 
								&compcode, &reason);
hFlds = MQeFieldsAlloc( hSess, FieldsType, 
								&compcode, &reason);
 
 
/* Put some fields in the fields 
	object using MQeFieldsPutByArrayOfFd() */
 
byteVal = 0xAE;
int16Val = 0x9876;
int32Val = 0x12345678;
 
/* Copy template */
memcpy(Fds,PFDS,sizeof(Fds));
 
Fds[0].fd_data = 
Fds[0].fd_datalen = 1;
Fds[1].fd_data = 
Fds[1].fd_datalen = 1;
Fds[2].fd_data = 
Fds[2].fd_datalen = 1;
Fds[3].fd_data = [0];
Fds[3].fd_datalen = sizeof(textVal);
 
compcode = MQECC_OK, reason = 0;
MQFieldsPutByArrayOfFd( hSess, hFlds, 
									Fds, NFDS, 
									&compcode, 
									&reason);
 
/* Copy template */
memcpy(Fds,PFDS,sizeof(Fds));
 
/* Get data lengths */
rc = MQeFieldsGetByArrayOfFd( hSess, hFlds, 
											Fds, NFDS, 
											&compcode, 
											&reason);
 
/* Get space for each field data */
for( i=0; i<rc; i++) {
 int len = Fds[i].fd_datalen*
				MQE_SIZEOF(Fds[i].fd_datatype);
 if (len > 0) {
  Fds[i].fd_data = (MQEBYTE *) malloc(len);
 } 
}
 
/* Get all the fields defined in field descriptor array in one shot */
compcode = MQECC_OK, reason = 0;
MQFieldsGetByArrayOfFd( hSess, hFlds, 
									Fds, NFDS, 
									&compcode, 
									&reason);

See Also
MQeFieldsPutByArrayOfFd,


© IBM Corporation 2002. All Rights Reserved