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 » Stripping X'' from BLOB

Post new topic  Reply to topic
 Stripping X'' from BLOB « View previous topic :: View next topic » 
Author Message
jonesn
PostPosted: Sun Feb 05, 2006 8:28 am    Post subject: Stripping X'' from BLOB Reply with quote

Apprentice

Joined: 09 Jan 2002
Posts: 47

Chaps,

I want to put InputRoot.MQMD.MsgId in a string field in a CWF message and would appreciate some advice on how best to do it.

It is complicated because the CWF message is returned back to me in the CDATA element of an XML instance document so I need to convert the message id into a string representation of blob to avaoid parser exceptions from binary characters (well, I think I do anyway!).

My latest attempt is to cast the message id to blob

Code:
declare msgIDBlob blob cast (InputRoot.MQMD.MsgId as blob CCSID InputRoot.MQMD.CodedCharSetId);


This gives me the following

Code:
X'414d51204d51534e4a30202020202020959ce34320044816'


This is what I expect but I now want to put this into my CWF message without the starting X' and trailing '.

I have tried substring but the function does not seem to include the X'' as part of the string I supply it so I end up with my substringed characters with an additional X''.

How can I get a string that contains only the following (from the above example)?

Code:
414d51204d51534e4a30202020202020959ce34320044816


Thanks
_________________
---

Nick Jones
IBM Certified Solutions Expert (WebSphere MQ Integrator)
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun Feb 05, 2006 9:59 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Substring...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jonesn
PostPosted: Sun Feb 05, 2006 10:45 am    Post subject: Reply with quote

Apprentice

Joined: 09 Jan 2002
Posts: 47

Jeff,

I have tried substring but the string returned still has the X'' surrounding the text.

Here is part of my eSQL...

Code:
declare msgIDBlob blob cast (InputRoot.MQMD.MsgId as blob CCSID InputRoot.MQMD.CodedCharSetId);
declare test1Char char cast (substring (msgIDBlob from 1 FOR 10) as char);
declare test2Char char cast (substring (msgIDBlob from 3 FOR 10) as char);


And here is part of the trace that it produced...

The first declaration produced the following...
Code:
The result was 'X'414d51204d51534e4a30202020202020959ce3432004481e''


The second declaration produced the following...

Code:
This resolved to 'SUBSTRING(X'414d51204d51534e4a30202020202020959ce3432004481e' FROM 1 FOR 10)'. The result was 'X'414d51204d51534e4a30''.


While the third produced the following...

Code:
This resolved to 'SUBSTRING(X'414d51204d51534e4a30202020202020959ce3432004481e' FROM 3 FOR 10)'. The result was 'X'51204d51534e4a302020''.


When these variables are inserted into my output message it has these extra X'' characters.
_________________
---

Nick Jones
IBM Certified Solutions Expert (WebSphere MQ Integrator)
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun Feb 05, 2006 12:23 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Sorry.

I meant something like
Code:
declare msgIDChar char cast (InputRoot.MQMD.MsgId as char CCSID InputRoot.MQMD.CodedCharSetId);
declare test1 char substring(msgIDChar from 3 for 48);


The X'' is the string representation of a BLOB variable. You won't ever get rid of it as long as you are implicitly or explicitly casting a BLOB as a character/string.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jonesn
PostPosted: Thu Feb 09, 2006 9:41 am    Post subject: Reply with quote

Apprentice

Joined: 09 Jan 2002
Posts: 47

Jeff,

What you suggest does not help because I am left with the character representation of the message id, i.e. control characters that cannot be included in the CDATA section of an XML instance document.

Code:
'AMQ MQSNJ0      v?C 0002'


I need the hex string but would like to lose the X'' bits. Surely with a bit of casting I should be able to convert

Code:
X'414d51204d51534e4a30202020202020959ce3432004481e'


to

Code:
414d51204d51534e4a30202020202020959ce3432004481e


Thanks
_________________
---

Nick Jones
IBM Certified Solutions Expert (WebSphere MQ Integrator)
Back to top
View user's profile Send private message
JT
PostPosted: Thu Feb 09, 2006 9:54 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Give this a try (un-tested):

Quote:
DECLARE msgIDBlob BLOB CAST(InputRoot.MQMD.MsgId AS BLOB CCSID InputRoot.MQMD.CodedCharSetId);
DECLARE msgIDChar CHARACTER CAST(msgIDBlob AS CHARACTER);
SET msgIDChar = SUBSTRING(msgIDChar FROM 3 FOR 48);
Back to top
View user's profile Send private message
jonesn
PostPosted: Thu Feb 09, 2006 10:05 am    Post subject: Reply with quote

Apprentice

Joined: 09 Jan 2002
Posts: 47

JT,

Thanks for that, it seems to work as I want.

Any chance you could explain why/how it works? The quirks of casting with or without CCSID seem confusing ;-}
_________________
---

Nick Jones
IBM Certified Solutions Expert (WebSphere MQ Integrator)
Back to top
View user's profile Send private message
EddieA
PostPosted: Thu Feb 09, 2006 10:31 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Actually, you only need this:
Code:
DECLARE msgIDChar CHARACTER CAST(InputRoot.MQMD.MsgId AS CHARACTER);
SET msgIDChar = SUBSTRING(msgIDChar FROM 3 FOR 48);

In fact, adding the 1st CAST could change the data (I think ).

Using a CCSID, the CAST will convert the data from the original Code Page to the new one, character by character.

Without a CCSID, the CAST will just convert each nibble (??) of the data to the corresponding character. So, the string is twice the size of the input.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Stripping X'' from BLOB
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.