MQeFieldsPutFields

Description
Puts an MQeFields object into another MQeFields object. The MQeFields object that is being put into the other MQeFields object becomes invalid after the API call. An MQeFields object cannot be inserted into itself.

Syntax
#include <hmq.h> 
#include <hmqHelper.h> 
MQEINT32 MQeFieldsPutFields( MQEHSESS hSess, MQEHFIELDS hFlds1, 
              MQECHAR * pName, MQEHFIELDS hFlds2, 
              MQEINT32 * pCompCode, MQEINT32 * pReason)

Parameters

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

MQEHFIELDS hFlds1 - input
The MQeFields object that is receiving hFlds2.

MQECHAR * pName - input
A null terminated string containing the name of the field. A null or a zero length string is invalid.

MQEHFIELDS hFlds2 - input
The MQeFields object that is being moved into hFlds1. This MQeFields object becomes invalid after this API returns.

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_INVALID_ARGUMENT
Invalid pName or hFlds1 is the same as hFlds2 .

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";
const char * hello = "Hello World";
MQEHSESS  hSess;
MQEINT32  compcode;
MQEINT32  reason;
MQEHFIELDS hFlds1, hFlds2, hFlds3;
MQEBYTE * pData;
MQEINT32  rc;
 
hSess  = MQeInitialize("MyAppsName", 
				&compcode, &reason);
hFlds1 = MQeFieldsAlloc( hSess, FieldsType, 
									&compcode, &reason);
hFlds2 = MQeFieldsAlloc( hSess, FieldsType, 
										&compcode, &reason);
 
/* Put hFlds1 into hFlds2 */
rc   = MQeFieldsPut( hSess, hFlds1, "ibm", 
								MQE_TYPE_ASCII, hello, 
            				strlen(hello), 
								&compcode, &reason); 
rc   = MQeFieldsPutFields( hSess, hFlds2, 
										"ibmFields", 
               					hFlds1, 
										&compcode, 
										&reason);
/* hFlds1 is no longer valid */
 
/* Retrieve hFlds1 as hFlds3 from hFlds2 */
hFlds3 = MQeFieldsGetFields( hSess, hFlds2, 
											"ibmFields", 
											&compcode, 
               						&reason);
 
/* Extract the "ibm" field */
datalen = MQeFieldsGet( hSess, hFlds3, 
									"ibm", 
									&datatype, 
									NULL, 0, NULL, 
            					&compcode, 
									&reason); 
pData  = malloc(datalen+1);
datalen = MQeFieldsGet( hSess, hFlds3, "ibm", 
								&datatype, 
								pData, 0, datalen, 
            				&compcode, &reason); 
pData[datalen] = '\0';
printf("Field is %s\n", pData);
 
/* Free the fields resources */
MQeFieldsFree( hSess, hFlds3, 
					&compcode, 
					&reason);
MQeFieldsFree( hSess, hFlds2, 
					&compcode, 
					&reason);

See Also
MQeFieldsGetFields


© IBM Corporation 2002. All Rights Reserved