MQeFieldsWrite

Description
Writes into the data block of an existing field in an MQeFields object. Returns the number of elements written, or '-1' if an error occurs.

Syntax
#include <hmq.h>
MQEINT32 MQeFieldsWrite( MQEHSESS hSess, 
				MQEHFIELDS hFlds, MQECHAR * pName, 
           MQEBYTE DataType, MQEINT32 dstOffset, 
           MQEBYTE * pSrcBuf, MQEINT32 srcLen, 
           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
The field name. A null or a zero length string is invalid.

MQEINT32 DataType - input
The data type of field. The types MQE_TYPE_FIELDS and MQE_TYPE_BOOLEAN are invalid.

MQEINT32 * dstOffset - input
The offset into the field data to start the write

MQEBYTE * pSrcBuf - input
The source buffer

MQEINT32 srcLen - input
The number of elements of type DataType to write.

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_ARGUMENT
Invalid inputs. For example, pSrcBuf is a NULL

MQE_EXCEPT_TYPE
DataType does not match data type of the field.

MQE_EXCEPT_NOT_FOUND
No field with name pName found in hFlds

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_EOF
End of field reached.

MQE_EXCEPT_ALLOCATION_FAILED

Return Value

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

Example
#include <hmq.h>
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
MQEHSESS  hSess;
MQEHFIELDS hFlds;
MQEINT32  compcode;
MQEINT32  reason;
MQEINT32  i, nread;
MQECHAR  buf[64];
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
								&compcode, 
								&reason);
hFlds  = MQeFieldsAlloc( hSess, FieldsType, 
									&compcode, 
									&reason);
 
/* Allocate a 128 byte buffer field */
rc = MQeFieldsPut( hSess, hFlds, "y" , 
							MQE_TYPE_BYTE, 
							NULL, 128, 
         				&compcode, 
							&reason); 
 
/* Fill the buffer with values 0-127 */
for (i=0; i<128; i++) {
char c=i;
MQeFieldsWrite( hSess, hFlds, "y", 
						MQE_TYPE_BYTE, i, 
						&c, 1, 
        				&compcode, 
						&reason); 
}
 
/* Read 64 byte out into an output buf, nread = 64 */
nread = MQeFieldsRead( hSess, hFlds, "y", 
								MQE_TYPE_BYTES, 
								buf, 0, 64, 
								NULL, 
            				&compcode, 
								&reason);

See Also


© IBM Corporation 2002. All Rights Reserved