Author |
Message
|
my_mqmb |
Posted: Sat May 12, 2012 12:59 am Post subject: Hexadecimal value of a decimal in ESQL ? |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
How do i convert hexadecimal value of a decimal in ESQL ?
like for example :
15 should be represented as F.
any 1 can help me with the code snippet ?
 |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun May 13, 2012 5:26 am Post subject: Re: Hexadecimal value of a decimal in ESQL ? |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
my_mqmb wrote: |
How do i convert hexadecimal value of a decimal in ESQL ?
like for example :
15 should be represented as F.
any 1 can help me with the code snippet ?
 |
Can you be more specific to what you are trying to do?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
my_mqmb |
Posted: Sun May 13, 2012 11:05 pm Post subject: Re: Hexadecimal value of a decimal in ESQL ? |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
fjb_saper wrote: |
Can you be more specific to what you are trying to do?  |
I am trying to convert length of some string which is in integer value to its HEX equivalent ..
decimal to hex conversion ...
if the length is 15 i need the hex_length to be 'F'
how to convert using esql (not java) |
|
Back to top |
|
 |
mqsiuser |
Posted: Sun May 13, 2012 11:19 pm Post subject: Re: Hexadecimal value of a decimal in ESQL ? |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Either write a custom FUNCTION ...
which does the transformation based on an (input) CHAR/INT (and on the individual characters/integers (use the SUBSTRING function))...
... or probably you can use the ASBITSTREAM or CAST function. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 14, 2012 12:28 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
'hex' is an overloaded word. It can mean
a) a string containing the characters '0'..'9','A'..'F' with each pair of characters representing a byte value or
b) a raw byte value interpreted as a number using the twos-complement encoding. Can be little-endian or big-endian if the number is multi-byte.
Which do you want? |
|
Back to top |
|
 |
my_mqmb |
Posted: Mon May 14, 2012 12:51 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
kimbert wrote: |
'hex' is an overloaded word. It can mean
a) a string containing the characters '0'..'9','A'..'F' with each pair of characters representing a byte value or
b) a raw byte value interpreted as a number using the twos-complement encoding. Can be little-endian or big-endian if the number is multi-byte.
Which do you want? |
thanks kimbert for your reply..
what i need is option (b) where i am converting the value of the whole integer into hexadecimal form .
(not representing each pair of character in a string) |
|
Back to top |
|
 |
my_mqmb |
Posted: Mon May 14, 2012 12:56 am Post subject: Re: Hexadecimal value of a decimal in ESQL ? |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
mqsiuser wrote: |
Either write a custom FUNCTION ...
which does the transformation based on an (input) CHAR/INT (and on the individual characters/integers (use the SUBSTRING function))...
... or probably you can use the ASBITSTREAM or CAST function. |
i have written a custom function to convert using 16 as the divisor for HEXADECIMAL.
but i need to know how it could be possible using ASBITSTREAM or CAST ?
when i use asbitstream it will treat it character by character which i dont want .
say for example 53 is represented in blob as X'0503'
what i need is its hexadecimal value ie 35 |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 14, 2012 1:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Have you tried this?
Code: |
CAST myInteger AS BLOB |
|
|
Back to top |
|
 |
my_mqmb |
Posted: Mon May 14, 2012 2:32 am Post subject: |
|
|
Voyager
Joined: 08 Jun 2011 Posts: 84
|
kimbert wrote: |
Have you tried this?
Code: |
CAST myInteger AS BLOB |
|
hmmm , thnx pretty straightforward ! |
|
Back to top |
|
 |
|