MQeFieldsCopy

Description
Copy one or all fields from one MQeFields object to another.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsCopy( MQEHSESS hSess, MQEHFIELDS hSrcFlds, 
            MQEHFIELDS hDstFlds, MQEINT32 Option, 
            MQECHAR * pName, MQEINT32 * pCompCode, 
            MQEINT32 * pReason)

Parameters

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

MQEHFIELDS hSrcFlds - input
The handle of the source MQeFields object.

MQEHFIELDS hDstFlds - input
The handle of the destination MQeFields object.

MQEINT32 Option - input

MQE_FIELDS_OPTION_NONE
This is the default option. It copies the specified field from the source MQeFields object to the destination MQeFields object, but does not replace the data if the field is found in the destination MQeFields object.

MQE_FIELDS_OPTION_ALL_FIELDS
If specified, this API copies all fields from the source MQeFields object to the destination MQeFields object.

MQE_FIELDS_OPTION_REPLACE
If specified, this API overwrites any fields in the destination MQeFields object that have the same field name as the field from the source MQeFields object.

MQECHAR * pName - input
A null terminated string containing the name of the field. If MQE_FIELDS_OPTION_ALL_FIELDS is specified, then this parameter is ignored. A null or a zero length string is invalid.

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_NOT_FOUND
Field name not found.

MQE_EXCEPT_INVALID_HANDLE

MQE_EXCEPT_INVALID_ARGUMENT
Field name too short or too long.

MQE_EXCEPT_ALLOCATION_FAILED

Return Value

MQEINT32

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

Example
#include <hmq.h>
#include <hmqHelper.h>
static MQECHAR const * FieldsType = 
			"com.ibm.mqe.MQeFields";
static const MQECHAR * textVal = 
			"The Owl and the Pussy Cat went to sea";
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds1, hFlds2;
MQEINT32  n;
MQEBYTE * pData;
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
								&compcode, 
								&reason);
hFlds1 = MQeFieldsAlloc( hSess, FieldsType, 
									&compcode, 
									&reason);
rc   = MQeFieldsPut( hSess, hFlds1, 
								"ibm", 
								MQE_TYPE_UNICODE, 
								strlen(textVal)), 
           				 textVal, 
								&compcode, 
								&reason); 
 
MQeFieldsCopy( hSess, hFlds1, 
						hFlds2, 
						MQE_FIELDS_OPTION_ALL_FIELDS, 
						NULL, 
       				&compcode, 
						&reason);
 
n    = MQeFieldsDataLen( hSess, 
									hFlds2, 
									"ibm", 
									&compcode, 
									&reason);
 
pData  = (MQEBYTE *) 
			calloc(n, MQE_SIZEOF(datatype));
 
/* Copy out the data */
rc   = MQeFieldsGetAscii( hSess, 
									hFlds2, 
									"ibm", 
									pData, n, 
              				&compcode, 
									&reason);

See Also
MQeFieldsGet


© IBM Corporation 2002. All Rights Reserved