Data Type Conversion - Please help

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
ramesh_ct
Participant
Posts: 5
Joined: Wed Sep 08, 2004 4:40 am

Data Type Conversion - Please help

Post by ramesh_ct »

Dear All,

I'm novice to DataStage... I have problem converting data type, please help. I have a source field having SQL Type as NCHAR where as target field having SQL Type as VARCHAR, how can I do this in Transfaormer stage... doesn't look like existing built-in data type conversion will help.

best regards
Ramesh
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

DataStage does lots of data type conversion automatically. Leave the metadata on the source and the targets alone. Just import them from the database of your choice. If you route data from one column to the target normally it will do whatever conversion is necessary behind the scenes to get the data there. This is one of the strengths of DataStage.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard! :D

One of the strengths of DataStage is that it's very tolerant of data type mismatches, as it doesn't use data types internally. So the correct way to perform this conversion, as Kim says, is to do nothing!

If you're really worried about it you could apply a Trim() or TrimB() function to the data value, to guarantee that trailing space is removed, but that's more for your peace of mind than necessary.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ramesh_ct
Participant
Posts: 5
Joined: Wed Sep 08, 2004 4:40 am

Post by ramesh_ct »

Hi Duke & Ray

Thanks for your inputs.

As you recommend I have left the data type of source & target fields to their defaults. The source field stores the values N or S of Data type NCHAR but when I check the target field (VARCHAR) in an Enterprise manager, I see a strange 'square' character. As Ray suggested to use TrimB function but no actual result. Any guess?

Thanks
Ramesh
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You need to find out what this character is. Most likely it is either tab char(9) or CrLf char(13) or char(10). You can strip these out with convert(), change() or oconv() functions. Do a search these have been covered a lot.
Mamu Kim
ramesh_ct
Participant
Posts: 5
Joined: Wed Sep 08, 2004 4:40 am

Post by ramesh_ct »

I changed the SQL Type to VARCHAR in the Input link of the transformer stage, it worked.

Thanks
Ramesh
Post Reply