convert from number to binary
Moderators: chulett, rschirm, roy
convert from number to binary
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.
thank you.
Pey
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.
thank you.
Pey
-
- Premium Member
- Posts: 385
- Joined: Tue Oct 07, 2003 4:55 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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
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
-
- Premium Member
- Posts: 224
- Joined: Tue Sep 24, 2002 7:32 am
- Location: Denver, CO USA
You are correct; as far as I know DataStage cannot convert a numeric string to binary. We had to write our own utility.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
John
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Didja try the "MX" conversion specification?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
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
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.