|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Casting hexadecimal to blob to character |
« View previous topic :: View next topic » |
Author |
Message
|
GaryGWood |
Posted: Fri Mar 04, 2005 12:01 pm Post subject: Casting hexadecimal to blob to character |
|
|
Apprentice
Joined: 14 Oct 2003 Posts: 48 Location: Austin, TX
|
I have an application that passes around XML messages in a variety of languages including some double byte ones (Japanese, Chinese, etc.). Fields using characters were not translating across the system and the fix from IBM support was the following:
In the SQL selecting the records, change
to
Code: |
hex(desc_txt) as desc1, |
This gets me the string in hexadecimal format. Then before the eval statement, use the following:
Code: |
SET InputDestinationList.XML.MessageData[J].DESC1 = CAST(CAST( InputDestinationList.XML.MessageData[J].DESC1 as blob) as CHARACTER CCSID 1208); |
This results in the error: An attempt was made to cast the character string
'Message #1' to a byte string, but the string was of the wrong format. There must be an even number of hexadecimal digits (0-9, a-f, A-F).
Looking around here it looks like I needed to add a CCSID parameter to the CAST going from the hexadecimal string into a blob:
Code: |
SET InputDestinationList.XML.MessageData[J].DESC1 = CAST(CAST( InputDestinationList.XML.MessageData[J].DESC1 as blob CCSID 1208) as CHARACTER CCSID 1208); |
(The "J" in this is a counter as I loop through the result set) This gets me past the error and messages land on the queue but the DESC1 field remains in hexadecimal format, not the chraacter text format I want.
Any ideas what I'm missing here to get back into text from hex? |
|
Back to top |
|
 |
shalabh1976 |
Posted: Mon Mar 07, 2005 1:21 am Post subject: |
|
|
 Partisan
Joined: 18 Jul 2002 Posts: 381 Location: Gurgaon, India
|
Did you play around with the CCSID value of the first CAST.
I know that 437 will work on Windows Box ?
Just try with the value on your box. _________________ Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate |
|
Back to top |
|
 |
GaryGWood |
Posted: Mon Mar 07, 2005 6:12 am Post subject: |
|
|
Apprentice
Joined: 14 Oct 2003 Posts: 48 Location: Austin, TX
|
Thanks for the reply.
I tried CCSID 437 but everything still comes across in hexadecimal. I keep thinking there must be some command around here that converts it from hex to ascii but can't seem to locate that ...  |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 07, 2005 6:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Replace your hardcoded CCSIDs with InputRoot.Properties.CodedCharSetID.
CAST uses the CCSID to tell the parser what CCSID the data is *in*, not what CCSID it *should be* in.
Also, what is "InputDestinationList"?
You should be using Environment, InputRoot, or InputLocalEnvironment, I think. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fazz |
Posted: Mon Mar 14, 2005 8:54 am Post subject: |
|
|
 Centurion
Joined: 20 Feb 2004 Posts: 144 Location: England
|
Slightly different, but I think you are trying to get the same result, this worked for me -
Code: |
DECLARE blbCDATA BLOB;
DECLARE chrDATA CHAR InputBody.IBISMSG.APPDATA.(XML.CDataSection);
SET blbCDATA = CAST(chrDATA AS BLOB);
SET chrDATA = CAST(blbCDATA AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding); |
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|