ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to Convert BLOB to CHAR

Post new topic  Reply to topic Goto page 1, 2  Next
 How to Convert BLOB to CHAR « View previous topic :: View next topic » 
Author Message
ashritha
PostPosted: Thu Oct 29, 2009 7:53 am    Post subject: How to Convert BLOB to CHAR Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

Hi,

I have a text message(in undefined format) which i am reading in MQ input node using BLOB parser. Message set could not be created as the incoming message has no pre-defined structure. Now, once the input is read, I want to populate that into a string variable for further transformation.

Code:
Set Environment.Variables.IncomingMessage = InputRoot.BLOB;
Set Value1 = CAST(InputRoot.BLOB as CHAR);
Set Value2 = CAST(Environment.Variables.IncomingMessage as CHAR);

No result is populate in Value1 and Value2 fields. However, the first statement where the incoming blob message is put in the environment variables is working fine.

Can some one please help me understand how a BLOB(which is infact text in this case) message is converted into string?

Thanks,
Ashritha
Back to top
View user's profile Send private message
ashritha
PostPosted: Thu Oct 29, 2009 8:11 am    Post subject: Reply with quote

Voyager

Joined: 25 Jul 2005
Posts: 85

Hi,

I solved the issue. The esql Statement should be

Set Value1 = CAST(InputRoot.BLOB.BLOB as char CCSID 1208 Encoding 815);

This works. Thought this might help for someone like me facing this issue.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Oct 29, 2009 7:54 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

ashritha wrote:
Hi,

I solved the issue. The esql Statement should be

Set Value1 = CAST(InputRoot.BLOB.BLOB as char CCSID 1208 Encoding 815);

This works. Thought this might help for someone like me facing this issue.


Even better would be:
Code:
Set Value1 = CAST(InputRoot.BLOB.BLOB as char CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Fri Oct 30, 2009 1:57 am    Post subject: Re: How to Convert BLOB to CHAR Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

ashritha wrote:
I solved the issue. The esql Statement should be
Code:
Set Value1 = CAST(InputRoot.BLOB.BLOB as char CCSID 1208 Encoding 815);

This works.

CASTs from BLOB to CHAR do not use the ENCODING parameter at all.

Otherwise the broker might have complained that 815 is not a valid ENCODING value.
Back to top
View user's profile Send private message
sirsi
PostPosted: Fri Oct 30, 2009 2:06 am    Post subject: Reply with quote

Disciple

Joined: 11 Mar 2005
Posts: 177

Quote:
CASTs from BLOB to CHAR do not use the ENCODING parameter at all.


what makes you think this?
Back to top
View user's profile Send private message
Bill.Matthews
PostPosted: Fri Oct 30, 2009 9:22 am    Post subject: Reply with quote

Master

Joined: 23 Sep 2003
Posts: 232
Location: IBM (Retired)

Do you understand what type of data ENCODING applies to?

Have you heard the terms "little-endian" and "big-endian"?

Hint: both terms apply to the same type of data.
_________________
Bill Matthews
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 30, 2009 9:44 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

The ESQL "CAST" section of the documentation explains exactly what Bill Matthews is talking about.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
nishantmodak
PostPosted: Fri Oct 30, 2009 3:35 pm    Post subject: Reply with quote

Novice

Joined: 25 May 2009
Posts: 19

Code:
 SET <VARIABLE> = CAST (InputRoot.BLOB.BLOB AS CHARACTER CCSID 1208) ;
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Oct 31, 2009 12:47 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

nishantmodak wrote:
Code:
 SET <VARIABLE> = CAST (InputRoot.BLOB.BLOB AS CHARACTER CCSID 1208) ;


Again even better would be:
Code:
 SET <VARIABLE> = CAST (InputRoot.BLOB.BLOB AS CHARACTER CCSID InputRoot.Properties.CodedCharSetId);

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sun Nov 01, 2009 8:51 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fjb_saper wrote:
Again even better would be:
Code:
 SET <VARIABLE> = CAST (InputRoot.BLOB.BLOB AS CHARACTER CCSID InputRoot.Properties.CodedCharSetId);


This is only actually true if InputRoot.BLOB.BLOB is still in the character set that is set in Properties. There are a number of ways in which this could not be true.
Back to top
View user's profile Send private message
sunny_30
PostPosted: Tue Nov 03, 2009 5:43 am    Post subject: Reply with quote

Master

Joined: 03 Oct 2005
Posts: 258

Hi Jeff,

You said:
Quote:
This is only actually true if InputRoot.BLOB.BLOB is still in the character set that is set in Properties


How can BLOB be in 'character' set ? Isnt BLOB always in 'Binary' mode ?

Do you mean the MQMD.Format has to be set to MQFMT_STRING ?
Do you mean Message-Broker cannot convert BLOB data when format is set to binary-> MQFMT_NONE ?

How is BLOB data (flowing in MessageBroker) "different" when the MQMD format is set to MQFMT_STRING compared to when format is set to MQFMT_NONE ?

Thanks,
Sunny
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Nov 03, 2009 6:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

What I meant was, that it is only valid to use InputRoot.Properties if the bytes contained in the blob actually represent characters in the CCSID that is in InputRoot.Properties.

You need to specify a CCSID that *correctly* indicates the code page that translates the byte values into character values.

The Format field of the MQMD has nothing to do with the contents of the BLOB data, nor with the contents of the bytes in the MQ message.

It does have something to do with what MQ will or will not do with the bytes in the MQ message, if you ask MQ to do something with those bytes. Broker provides means for you to ask MQ to do something with those bytes if you want.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Nov 04, 2009 2:57 am    Post subject: Re: How to Convert BLOB to CHAR Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

mqjeff wrote:
This is only actually true if InputRoot.BLOB.BLOB is still in the character set that is set in Properties. There are a number of ways in which this could not be true.

A really good practice is to ensure that Root.Properties.CodedCharSetID always matches Root.BLOB.BLOB, before propagating a message from one node to the next.

sunny_30 wrote:
Do you mean the MQMD.Format has to be set to MQFMT_STRING?

The CAST function does not use MQMD.Format.
Back to top
View user's profile Send private message
mqbrk_newbie
PostPosted: Mon Jul 12, 2010 5:26 pm    Post subject: How to Convert BLOB to CHAR Reply with quote

Acolyte

Joined: 13 Sep 2004
Posts: 70

Hello,

I was trying to convert a blob to character . I followed the same instruction as given above.

SET accNo = CAST (SUBSTRING(InputRoot.BLOB.BLOB FROM 21 FOR 9) AS CHAR CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);


I am getting a the following error:


The message broker detected an error whilst executing the given statement. An exception has been thrown to cut short th
e SQL program.
See the following messages for details of the error.
2010-07-12 20:18:50.534592 10274 RecoverableException BIP2590E: Error casting character string ''110181110'' to a byte string.
An attempt was made to cast the character string ''110181110'' 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).
Other messages will give an indication of context of this error.


I used different CCSID , But its not working. Can someone help me solve this issue.
Back to top
View user's profile Send private message Yahoo Messenger
fjb_saper
PostPosted: Mon Jul 12, 2010 6:36 pm    Post subject: Re: How to Convert BLOB to CHAR Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

mqbrk_newbie wrote:

I am getting a the following error:


The message broker detected an error whilst executing the given statement. An exception has been thrown to cut short th
e SQL program.
See the following messages for details of the error.
2010-07-12 20:18:50.534592 10274 RecoverableException BIP2590E: Error casting character string ''110181110'' to a byte string.
An attempt was made to cast the character string ''110181110'' 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).
Other messages will give an indication of context of this error.


I used different CCSID , But its not working. Can someone help me solve this issue.


Why use a different CCSID when the error is clearly described in the text!
Remember that a hex representation of a byte uses 2 characters or bytes.
So your FROM 21 FOR 9 should probably read FROM 42 FOR 18...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to Convert BLOB to CHAR
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.