MQeFieldsPutByArrayOfFd

Description
Creates a set of fields in the MQeFields object given an array of field descriptors. Returns the number of successfully processed descriptors, or '-1' if an error occurred before any descriptors were processed. Descriptors are processed in order and the call fails as soon as the first descriptor fails.

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

Parameters

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

MQEHFIELDS hFlds - input
The handle to an MQeFields object.

MQEFIELD * pFds - input
An array of struct MQeField_st field descriptors. Puts a field named fd_name into an MQeFields object with fd_datalen elements of type fd_datatype. The field data is taken from fd_data if it is not NULL, otherwise, the field data is set to zero. The fd_namelen field is not used by this call. The field name's length is determined from fd_name .

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

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

MQE_EXCEPT_ALLOCATION_FAILED

Return Value

MQEINT32
  • On success, returns the number of descriptors successfully put.
  • 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.";
static const MQEFIELD PFDS[] = {
          {MQE_TYPE_BYTE, 0, 0, "fooByte", 0, 0, 
					(MQEBYTE *)0},
          {MQE_TYPE_SHORT, 0, 0, "fooShort", 0, 0, 
					(MQEBYTE *)0},
          {MQE_TYPE_LONG, 0, 0, "fooLong", 0, 0, 
					(MQEBYTE *)0},
          {MQE_TYPE_ASCII, 0, 0, "fooText", 0, 0, 
					(MQEBYTE *)0}
    };
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds;
MQEBYTE  byteVal;
MQEINT16  int16Val;
MQEINT32  int32Val, 
				pDataLen[2], 
				*pDataLen2;
MQEVOID * ppData[4], 
			** ppData2, 
			**ppData3;
MQEINT32  rc, nFlds;
MQEINT32  i; 
MQEBYTE  datatype;
MQEFIELD * pFds;
 
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;
PFDS[0].fd_fd_datalen = sizeof(byteVal);
PFDS[1].fd_fd_datalen = sizeof(int16Val);
PFDS[2].fd_fd_datalen = sizeof(int32Val);
PFDS[3].fd_fd_datalen = strlen(textVal);
PFDS [0].fd_data = (MQEVOID *)&byteVal;
PFDS [1].fd_data = (MQEVOID *)&int16Val;
PFDS [2].fd_data = (MQEVOID *)&int32Val;
PFDS [3].fd_data = (MQEVOID *) textVal;
 
MQFieldsPutByArrayOfFd( hSess, hFlds, PFDS, 4, 
								&compcode, &reason);
 
/* Get the field lengths, not data */
for (i=0;i<4;i++) {
 PFDS[i].fd_fd_datalen = 0;
 PFDS[i].fd_data = (MQEVOID *)0;
}
nFlds = MQFieldsGetByArrayOfFd( hSess, hFlds, PFDS, 4, 
											&compcode, &reason);
 
if (nFlds > 0) {
 /* Get space for field data */
 for( i=0; i<nFlds; i++) {
   PFDS[i].fd_data = (MQEVOID *) 
   malloc(PFDS[i].fd_datalen*mqe_sizeof
								(PFDS[i].fd_datatype));
 }
 /* Get all the fields defined in field 
		descriptor array in one shot */
 nFlds = MQFieldsGetByArrayOfFd( hSess, hFlds, 
												PFDS, nFds, 
												&compcode, 
												&reason);
}

See Also
MQeFieldsGetByArrayOfFd,


© IBM Corporation 2002. All Rights Reserved