conversion from varbinary to varchar

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
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

conversion from varbinary to varchar

Post by major »

Hi,

I have a requirement

To extract varbinary fields from a table say X , do some manipualtions and inset the changed record in same table X.

But the problem is varbinary fields are getting changed
For eg in source table the field is like 202020 , when i extracted them to seq file they were becoming as 323032303230 . I tried putting convert(varchar,value)
function but this time empty spaces were coming .

I am using sysbase db.

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

Post by ray.wurlod »

323032303230 is the hex equivalent of "202020". So, somewhere, a "raw to hex" conversion was being performed, either automatically because you're reading it into a VarChar or because you asked for it somehow.

You can convert this back to raw (VarBinary) form using Oconv() with "MY" as the conversion specification. You can convert it to a string equivalent using Iconv() with "MX0C" as the 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.
major
Premium Member
Premium Member
Posts: 167
Joined: Mon Nov 26, 2007 12:21 am

Post by major »

ray.wurlod wrote:323032303230 is the hex equivalent of "202020". So, somewhere, a "raw to hex" conversion was being performed, either automatically because you're reading it into a VarChar or because you asked for it ...

hi,

Got it , i converted it explicitly to hex using iconv function

Thanks for you insight in the problem :D
Post Reply