VarChar to Hex
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
VarChar to Hex
Hi,
I need to convert varchar to hex value. There are 2 parts to it, first convert from varchar to hex but take only 2 at a time from the below source column:
SrcCol=56243312....
Required Output value (if we just consider the first 2 i.e. 56)
outputCol=00011100
Did any one come across sucha situation. I look at some Oconv function (radix) but not sure if it takes 2 caharacters at a time.
Thanks,
I need to convert varchar to hex value. There are 2 parts to it, first convert from varchar to hex but take only 2 at a time from the below source column:
SrcCol=56243312....
Required Output value (if we just consider the first 2 i.e. 56)
outputCol=00011100
Did any one come across sucha situation. I look at some Oconv function (radix) but not sure if it takes 2 caharacters at a time.
Thanks,
Thanks,
Vinay
Vinay
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You would need a BASIC Transformer to use Oconv() or Iconv() in a parallel job. But your output isn't hex - it appears to be binary. Oconv() can do that too. Please specify your exact requirements. Hex can be managed with "MX" or "MX0C" or "MY" conversion, binary with "MB" or "MB0C").
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
Hi Ray,
Sorry for the confusion, yes I need the binary output. I designed it with the basic transformer and got the output, how ever is there away to keep the leading zeros with any options:
56=11100 (Can we get 00011100)
Secondly, do we have any options we can mention in the function so that it takes 2 characters at a time, as the source is like
564286988989.....
thanks a lot.
Sorry for the confusion, yes I need the binary output. I designed it with the basic transformer and got the output, how ever is there away to keep the leading zeros with any options:
56=11100 (Can we get 00011100)
Secondly, do we have any options we can mention in the function so that it takes 2 characters at a time, as the source is like
564286988989.....
thanks a lot.
Thanks,
Vinay
Vinay
Vinaymanchinila,
even though I'm not Ray you can right pad your binary to 8 places by using the FMT(In.Column,'8"0"R') conversion. I'm not sure what you are trying to do with the "take 2 characters at a time" part.
even though I'm not Ray you can right pad your binary to 8 places by using the FMT(In.Column,'8"0"R') conversion. I'm not sure what you are trying to do with the "take 2 characters at a time" part.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
With ICONV/OCONV use the MX format for hexadecimal, MB for binary.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Two characters at a time can be done simply in a server routine with a loop. Be sure to handle exceptions, such as argument not assigned, argument not null, argument contains odd number of digits, argument does not contain decimal numbers. You can invoke the server routine from any expression in your BASIC Transformer stage.
Or you could create parallel routines that you could invoke from a parallel Transformer stage. Or a BuildOp.
Or you could create parallel routines that you could invoke from a parallel Transformer stage. Or a BuildOp.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.