Author |
Message
|
kuladeep.dairy |
Posted: Sun Nov 01, 2009 4:22 pm Post subject: Converting an integer to a corresponding hexadecimal string. |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
Hi, I need to construct a correlation id from an application specific value(e.g policy number). for this i need to construct a hexadecimal string.please help. |
|
Back to top |
|
 |
Vitor |
Posted: Sun Nov 01, 2009 5:41 pm Post subject: Re: Converting an integer to a corresponding hexadecimal str |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kuladeep.dairy wrote: |
Hi, I need to construct a correlation id from an application specific value(e.g policy number). |
It's very seldom a good idea to use a non-WMQ generated id value. Be sure you've reviewed the discussions on this forum on this subject so you're aware of the restrictions, shortcomings and pitfalls of this method.
Having said that, are you trying to do this in Java, ESQL or what? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 8:21 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
Hi Vitor, Thanks your the response.
I might have to do that...
And,I was trying to it in ESQL. Can you please suggest a way to do this.I went thru the documentation. But I coudnt find any functions/ways to do it/ |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Nov 01, 2009 9:46 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
kuladeep.dairy wrote: |
Hi Vitor, Thanks your the response.
I might have to do that...
And,I was trying to it in ESQL. Can you please suggest a way to do this.I went thru the documentation. But I coudnt find any functions/ways to do it/ |
Well in ESQL the correlId is not a hex string but a BLOB. You may not appreciate the subtle difference but it is there. You can append hex 00 to the end of your BLOB to get up to 24 bytes.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 10:10 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
Thanks Pooba. I was thinking of converting a policy number, say 12345678 to hexa decimal string and append '00' to make it to the length of a correlid.
I was wonding if there is a function or a way to convert this 12345678 to the corresponding hex string.
or do we have to write our own function? |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 01, 2009 10:47 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
kuladeep.dairy wrote: |
Thanks Pooba. I was thinking of converting a policy number, say 12345678 to hexa decimal string and append '00' to make it to the length of a correlid.
I was wonding if there is a function or a way to convert this 12345678 to the corresponding hex string.
or do we have to write our own function? |
To restate what has been said by fjb, the MsgId & CorrelId in an MQ MQMD are BLOB fields not hex strings.
There are many posts in this forum about using the MsgId & CorrelId field for various things. There are also posts about converting character stribgs to Blob's.
Please tell us what you have tried for yourself. This way we can avoid suggesting things you have already tried. _________________ 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 |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 11:10 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
Hi,Thank you. messageId&correlId are BLOB's;i got that point.
i had tried the below code. and it is constructing a blob that works as a correlId.
DECLARE corelID CHAR Environment.Variables.Policy||LossfDate;
SET OutputRoot.MQMD.CorrelId =CAST(corelID||corelID||corelID AS BLOB)
(* the length of this char variable, CorrelId is 16 chars. to get 48 characters it is appended twice to itself)
But by looking at a typical msgid/correlId(e.g. 414d51204346514d20202020202020203e7ce74a20079d05) I thought that msgid/correlid consists of a hexa decimal string.So i was trying to convert my char string to a hex string.
I wanted to know if there is any way to do it in ESQL. (May be we have to write our own function for going thru all chars in the string and convetin them to the corresponding hex digits.) |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 01, 2009 11:26 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
BLOB's are typically shown (especially in tools like rfhutil) as a string of HEX Characters simply because there is no way to parse them because they are BLOB's.
Ok, you have made a start.
One suggestion would be to create a string of characters full of '0'. Then OVERLAY on top of that the data you want in your string and then convert that to a BLOB. That should get rid of the padding.
It also helps if you put code (aka ESQL) in CODE tags.
Finally, NO, you don't have to write a special function to do this.
/Stephen D _________________ 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 |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 11:27 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
hmm..okay
414d51204346514d20202020202020203e7ce74a20079d05 in this 41 represents just a byte!! .... |
|
Back to top |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 11:30 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
sorry.My bad.I got what i wanted. Thanks for the help. |
|
Back to top |
|
 |
kuladeep.dairy |
Posted: Sun Nov 01, 2009 11:34 pm Post subject: |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
smdavies99,
Thank you for your suggestion! |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 01, 2009 11:52 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Please let us know your solution so that others can benefit as well _________________ 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 |
|
 |
kuladeep.dairy |
Posted: Mon Nov 02, 2009 12:46 am Post subject: BLOB's are typically shown (especially in tools like rfhutil |
|
|
Apprentice
Joined: 11 Jul 2009 Posts: 38
|
Davis,
while you were composing that last but one post, i sent those 2 msgs, i am going to implement your suggestion. Thanks a lot for your help |
|
Back to top |
|
 |
|