#include <hmq.h> #include <hmqHelper.h> MQEINT32 MQeFieldsGetAsciiArray( MQEHSESS hSess, MQEHFIELDS hFlds, MQECHAR * pName, MQECHAR * ppData[], MQEINT32 pDataLen[], MQEINT32 srcOff, MQEINT32 n, MQEINT32 * pCompCode, MQEINT32 * pReason) MQEINT32 MQeFieldsGetUnicodeArray( MQEHSESS hSess, MQEHFIELDS hFlds, MQECHAR * pName, MQEINT16 * ppData[], MQEINT32 pDataLen[], MQEINT32 srcOff, MQEINT32 n, MQEINT32 * pCompCode, MQEINT32 * pReason) MQEINT32 MQeFieldsGetByteArray( MQEHSESS hSess, MQEHFIELDS hFlds, MQECHAR * pName, MQEBYTE * ppData[], MQEINT32 pDataLen[], MQEINT32 srcOff, MQEINT32 n, MQEINT32 * pCompCode, MQEINT32 * pReason)
#include <hmq.h> #include <hmqHelper.h> static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields"; static const MQECHAR * textArray[] = { "The Owl and the Pussy Cat went to sea", "Here we go round the Mulberry bush", "Jack and Jill went up the hill" }; MQEHSESS hSess; MQEINT32 compcode; MQEINT32 reason; MQEHFIELDS hFlds; MQEINT32 pStrLen[3], n, *pStrLen2; MQEBYTE * pData; MQEINT32 rc; hSess = MQeInitialize("MyAppsName", &compcode, &reason); hFlds = MQeFieldsAlloc( hSess, FieldsType, &compcode, &reason); pStrLen[0] = strlen(textArray[0]); pStrLen[1] = strlen(textArray[1]); pStrLen[2] = strlen(textArray[2]); rc = MQeFieldsPutAsciiArray( hSess, hFlds, "ibm", textArray, pStrLen, 3, &compcode, &reason); /* 1. Get number of elements */ n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", NULL, NULL, 0, 0, &compcode, &reason); /* Get space for array of string length */ pStrLen2 = (MQEINT32 *) malloc(n * sizeof(MQEINT32)); memset(pStrLen2, 0, n * sizeof(MQEINT32)); /* 2. Get array of string length */ n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", NULL, pStrLen2, 0, n, &compcode, &reason); /* Get space for array of string */ for (i=0; i<n; i++) { pStr[i] = (MQECHAR *) malloc(pStrLen[j]+1); memset(pStr[i], 0, pStrLen[j]+1); } /* 2. Get array of strings */ n = MQeFieldsGetAsciiArray( hSess, hFlds, "ibm", pStr, pStrLen2, 0, n, &compcode, &reason);