MQeFieldsRead

Description
Reads a portion of a field's data block. Returns the number of elements read, or '-1' if an error occurred.

Syntax
#include <hmq.h>
MQEINT32 MQeFieldsRead( MQEHSESS hSess, 
				 MQEHFIELDS hFlds, MQECHAR * pName, 
            MQEBYTE DataType, MQEVOID * pDestBuf, MQEINT32 srcOff, 
            MQEINT32 srcLen, 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
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 named field. It must match the data type of the field in the MQeFields object. The value MQE_TYPE_FIELDS in not a valid argument.

MQEBYTE * pDestBuf - output
The destination buffer for the read operation

MQEINT32 srcOff - input
The offset position into the field data to start the read.

MQEINT32 srcLen - input
Number of bytes to read

MQEVOID * pBase - input
The base pointer for the destination buffer pDestBuf .

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, pDestBuf is a NULL.

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_NOT_FOUND
The named field is not in the MQeFields object.

MQE_EXCEPT_TYPE
The type of the named field does not match DataType .

MQE_EXCEPT_DATA
The field data is not suitable for reading, (for example too short or null)

MQE_EXCEPT_EOF
The srcOff starts beyond the end of the field's data block.

Return Value

MQEINT32
  • On success, returns the number of elements read successfully.
  • 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" , i, &c, 1, 
						&compcode, &reason); 
}
 
/* Read 64 byte out into an output buf, nread = 64 */
nread = MQeFieldsRead( hSess, hFlds, "y", 
								MQE_TYPE_BYTE, 
									buf, 0, 64, NULL, 
            				&compcode, &reason);

See Also


© IBM Corporation 2002. All Rights Reserved