Author |
Message
|
nelson |
Posted: Sat Apr 20, 2013 10:46 am Post subject: Error when parsing MQ Destination Data Correlation Id |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
Hi all,
I have this flow:
FileInput -> MQOutput -> Database
I need to insert the value of
Code: |
$LocalEnvironment/WrittenDestination/MQ/DestinationData[1]/correlId |
into a database table. The message that is put in the queue has CCSID 1208 and Encoding 273.
Debugging the flow I noticed that the $LocalEnvironment/WrittenDestination/MQ/DestinationData[1]/correlId field is in the BLOB domain:
Code: |
correlId:BLOB:[B@57165716 |
When I have tried to cast it within the database node:
Code: |
SET Corr = CAST(LocalEnvironment.WrittenDestination.MQ.DestinationData[1].correlId AS CHAR CCSID 1208 ENCODING 273); |
But get the following error:
Code: |
(0x01000000:Name ):RecoverableException = (
(0x03000000:NameValue):File = '/build/S610_P/src/CommonServices/ImbConverter.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 504 (INTEGER)
(0x03000000:NameValue):Function = 'ImbConverterCPP::internalToUnicode' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPv610' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2135 (INTEGER)
(0x03000000:NameValue):Text = 'Unconvertable character' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'ea' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '414d512042524b524341202020202020516fea7320042b1b' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 2 (INTEGER)
(0x03000000:NameValue):Text = '1208' (CHARACTER)
)
)
)
)
)
) |
How can I convert this value to CHAR? I have tried many CCSID - Enconding combinations but get the same error.
Any help is very appreciated. |
|
Back to top |
|
 |
rekarm01 |
Posted: Sat Apr 20, 2013 2:11 pm Post subject: Re: Error when parsing MQ Destination Data Correlation Id |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
nelson wrote: |
How can I convert this value to CHAR? I have tried many CCSID - Enconding combinations but get the same error. |
The Correlation Id contains arbitrary binary data. It does not represent a character string. To convert from BLOB to hexadecimal to CHAR instead, omit the CCSID (and Encoding):
Code: |
SET Corr = CAST(LocalEnvironment.WrittenDestination.MQ.DestinationData[1].correlId AS CHAR); |
|
|
Back to top |
|
 |
nelson |
Posted: Sat Apr 20, 2013 4:41 pm Post subject: Re: Error when parsing MQ Destination Data Correlation Id |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
rekarm01 wrote: |
nelson wrote: |
How can I convert this value to CHAR? I have tried many CCSID - Enconding combinations but get the same error. |
The Correlation Id contains arbitrary binary data. It does not represent a character string. To convert from BLOB to hexadecimal to CHAR instead, omit the CCSID (and Encoding):
Code: |
SET Corr = CAST(LocalEnvironment.WrittenDestination.MQ.DestinationData[1].correlId AS CHAR); |
|
Thank you rekarm01 for your response. When I cast the correl Id as a CHAR and omit the CCSID I get the following result:
Code: |
Corr:CHARACTER:X'414d512042524b524341202020202020516fea7320042b46' |
This is BLOB, but in this case what I need is the CHAR representation of this bytes. Since now this is a CHAR.. is it possible to cast this string to another representation?
Before your answer I was doing an experiment and it finally works. I was trying to have the same characters both in the database and in the correlation ID (I checked it in the MB Explorer). When using the CCSID 1208 I get the error in the 'EA' bytes. Drilling up a little on this I discovered that the ASCII Extended representation of the bytes 'EA' corresponds to the value that is displayed in the MQ Explorer (ê). So I tried with the ISO 8859-1 ASCII CCSID (819) and the correlId was parsed correctly.
So this is what I did:
Code: |
SET Corr = CAST(LocalEnvironment.WrittenDestination.MQ.DestinationData[1].correlId AS CHAR CCSID 819); |
Note: What Message Broker generates as correlId is (this is what MB Explorer shows):
and the bytes are:
Code: |
414d512042524b524341202020202020516fea7320042b46 |
My answer here is, under which CCSID does Message Broker generate this ID?
Thanks in advance. |
|
Back to top |
|
 |
mqjeff |
Posted: Sat Apr 20, 2013 4:54 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Broker does not generate this value.
MQ does.
MQ does not use any CCSID to generate this value.
It does not represent a character string.
It is exactly and only what MQ defines it to be. An array of bytes (NOT characters) that is 24 bytes long.
You can not continue to pretend that this is meaningful in any way as a character value, nor store or retrieve it as one.
You can choose to instruct Broker to populate these 24 bytes with bytes that happen to represent 24 (or less) characters, in any CCSID you want.
But to do so you will have to generate those characters yourself. |
|
Back to top |
|
 |
nelson |
Posted: Sat Apr 20, 2013 7:56 pm Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
mqjeff wrote: |
Broker does not generate this value.
MQ does.
MQ does not use any CCSID to generate this value.
It does not represent a character string.
It is exactly and only what MQ defines it to be. An array of bytes (NOT characters) that is 24 bytes long.
You can not continue to pretend that this is meaningful in any way as a character value, nor store or retrieve it as one.
You can choose to instruct Broker to populate these 24 bytes with bytes that happen to represent 24 (or less) characters, in any CCSID you want.
But to do so you will have to generate those characters yourself. |
Now it makes sense to me.. I can clearly see what I was doing wrong. It is just an array of bytes.
mqjeff, thanks a lot for your explanations.
rekarm01, now I understand what you were trying to tell me. Thanks for your help. |
|
Back to top |
|
 |
McueMart |
Posted: Mon Apr 22, 2013 12:18 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Look up Base 64 encoding if you really want to encode binary data in a text string. |
|
Back to top |
|
 |
|