convert from number to binary

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Peytot
Participant
Posts: 145
Joined: Wed Jun 04, 2003 7:56 am
Location: France

convert from number to binary

Post by Peytot »

Hello,
I would like to get the lenght of a field and put the result in a binary field.

ex: Len(name), but when I do this the result is not in Binary format even if I define the field bin. :twisted:

thank you.

Pey
Amos.Rosmarin
Premium Member
Premium Member
Posts: 385
Joined: Tue Oct 07, 2003 4:55 am

Post by Amos.Rosmarin »

Do you mead 010010101..... like they use in computers

You can use Oconv ( number , "MB" )

to the opossite direction use Iconv (xx , "MB")


HTH,
Amos
Peytot
Participant
Posts: 145
Joined: Wed Jun 04, 2003 7:56 am
Location: France

Post by Peytot »

Thank you Amos,
I didn't think that It was so easy to do.

Pey
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You might also like to investigate the "MX0C" conversion, which converts each byte into two hex characters. For example, "ABC" becomes "313233".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
lebos
Participant
Posts: 74
Joined: Mon Jan 20, 2003 10:02 am
Location: USA

Post by lebos »

I could be wrong, but both of these solutions seem to give only a character representation of the desired result, at least when written to a Sequential File stage. For example:

oconv("9","MB") = "1001", not a true binary field, but rather an ASCII character field. (In hex it would be x31303031, I believe).

Is it possible to achieve a true binary field? So that the result would be x09? I have tried several combinations of oconv and iconv with no success.

Larry
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

lebos wrote:I could be wrong, but both of these solutions seem to give only a character representation of the desired result, at least when written to a Sequential File stage. For example:

oconv("9","MB") = "1001", not a true binary field, but rather an ASCII character field. (In hex it would be x31303031, I believe).

Is it possible to achieve a true binary field? So that the result would be x09? I have tried several combinations of oconv and iconv with no success.

Larry
You are correct; as far as I know DataStage cannot convert a numeric string to binary. We had to write our own utility.
John
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Post by Teej »

My kingdom for a Server Row Generator!

*grumbles about not able to test this easily*

-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

lebos wrote:I could be wrong, but both of these solutions seem to give only a character representation of the desired result, at least when written to a Sequential File stage. For example:

oconv("9","MB") = "1001", not a true binary field, but rather an ASCII character field. (In hex it would be x31303031, I believe).

Is it possible to achieve a true binary field? So that the result would be x09? I have tried several combinations of oconv and iconv with no success.

Larry
Didja try the "MX" conversion specification?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
lebos
Participant
Posts: 74
Joined: Mon Jan 20, 2003 10:02 am
Location: USA

Post by lebos »

Yes, I did Ray. It returns a character representation of the hex also, not an actual hex (binary) field. At least that's what it looks like to me.

Larry
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, it tends to be one-way traffic. You can convert from binary data into equivalent string representation (which is DataStage's internal representation) but not, it seems, the other way.
I'm certain there is a way, but can't remember right now (10:30pm in a Bangkok hotel, without DataStage) how to go about it. :cry:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply