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 » WBIMB: Converting a integer value to a blob value

Post new topic  Reply to topic
 WBIMB: Converting a integer value to a blob value « View previous topic :: View next topic » 
Author Message
Herbert
PostPosted: Sun Jan 21, 2007 11:13 pm    Post subject: WBIMB: Converting a integer value to a blob value Reply with quote

Centurion

Joined: 05 Dec 2006
Posts: 146
Location: Leersum, The Netherlands

Hello,

I need to convert a integer value to a blob value where every digit is a position, for example the integer value 123 must be converted to blob value x'313233'.

I have tried some CAST commands, but that was not working, I have below code working, however I need to speed it up, any hints?
Code:
      DECLARE INT INTEGER  123;  -- Input
      DECLARE BLB BLOB;       -- Output

      DECLARE CHR CHAR;      
      DECLARE LEN INTEGER;
      DECLARE HEX CHAR;      
      DECLARE IDX INTEGER;   

      SET CHR = CAST(INT AS CHAR);
      SET LEN = LENGTH(CHR);
      SET IDX = 1;
      SET HEX = '';

      WHILE (IDX <= LEN) DO
         SET HEX = HEX || '3' || SUBSTRING(CHR FROM IDX FOR 1);
         SET IDX = IDX + 1;   
      END WHILE;   

      SET LINE_BLB = CAST(HEX as BLOB);

Kind Regards, Herbert
Back to top
View user's profile Send private message Visit poster's website
Tibor
PostPosted: Mon Jan 22, 2007 4:39 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

Try this way:
Code:
set LINE = cast( cast(INT as character) as blob ccsid 437 );

The needed byte codes ('1' = 0x31, '2' = 0x32, etc.) are encoded in the ASCII character set, that's why the CCSID isn't optional.
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 » WBIMB: Converting a integer value to a blob value
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.