MQeFieldsPut

Description
Puts a field into the MQeFields object.

Syntax
#include <hmq.h>
MQEINT32 MQeFieldsPut( MQEHSESS hSess, MQEHFIELDS hFlds, 
            MQECHAR * pName, MQEBYTE DataType, 
            MQEVOID * pData, MQEINT32 nElements, 
            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
A null terminated string name of the field. A null or a zero length string is invalid.

MQEBYTE DataType - input
The data type of the field data. This parameter cannot be a null and its value must be one of the defined values. See Field data types.

MQEVOID * pData - input
The data buffer. If NULL, an internal buffer is allocated whose size is specified by the nElements parameter. You can then use MQeFieldsWrite to put data into this pre-allocated buffer. And this internal buffer is initialized to zeros for the data types,
  • MQE_TYPE_BYTE
  • MQE_TYPE_SHORT
  • MQE_TYPE_INT
  • MQE_TYPE_LONG
  • MQE_TYPE_ASCII
  • MQE_TYPE_UNICODE
  • MQE_TYPE_UNTYPED
  • MQE_TYPE_FLOAT
  • MQE_TYPE_DOUBLE

If DataType is MQE_TYPE_FIELDS, pData must not be null.

MQEINT32 nElements - input
The number of elements of type DataType in pData. This must be greater than '0'. If the DataType is MQE_TYPE_FIELDS, MQE_TYPE_ARRAY_ELEMENTS, or MQE_TYPE_BOOLEAN, nElements must '1'.

MQEINT32 * pCompCode - output
MQECC_OK, MQECC_WARNING or MQECC_ERROR.

MQEINT32 * pReason - output
If MQECC_ERROR, *pReason could be:

MQE_EXCEPT_INVALID_HANDLE
If either hSess or hFlds are invalid handles.

MQE_EXCEPT_INVALID_ARGUMENT
If an invalid argument is used.

MQE_EXCEPT_ALLOCATION_FAILED

Return Value

MQEINT32
Returns '0' on success, or '-1' on failure.

Valid input parameter combinations

pName DataType DataLen Data Comment
! null * >0 ! null Normal usage
! null * >0 null Preallocate a field data.
null * * * Error

Example
#include <hmq.h>
static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields";
MQEHSESS  hSess;
MQEHFIELDS hFlds;
MQEBYTE  datatype;
MQEINT32  n;
MQEINT32  data;
MQEINT32  compcode;
MQEINT32  reason;
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
								&compcode, 
								&reason);
hFlds  = MQeFieldsAlloc( hSess, 
									FieldsType, 
									&compcode, 
									&reason);
 
/* Put a 4-bytes integer into the fields object. */
datatype = MQE_TYPE_INT;
n    = 1;
data   = 0x12345678;
rc = MQeFieldsPut( hSess, hFlds, 
							"MyData", 
							datatype, 
							(MQEBYTE *) 
							&data, n, 
         				&compcode, 
							&reason);

See Also
MQeFieldsGet


© IBM Corporation 2002. All Rights Reserved