|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
WBIMB: Converting a integer value to a blob value |
« View previous topic :: View next topic » |
Author |
Message
|
Herbert |
Posted: Sun Jan 21, 2007 11:13 pm Post subject: WBIMB: Converting a integer value to a blob value |
|
|
 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 |
|
 |
Tibor |
Posted: Mon Jan 22, 2007 4:39 am Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
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
|
|
|
|