Page 1 of 1

Data Type Conversion - Please help

Posted: Wed Sep 08, 2004 4:47 am
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

Posted: Wed Sep 08, 2004 5:56 am
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.

Posted: Wed Sep 08, 2004 4:47 pm
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.

Posted: Thu Sep 09, 2004 4:40 am
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

Posted: Thu Sep 09, 2004 5:41 am
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.

Posted: Thu Sep 09, 2004 7:01 am
by ramesh_ct
I changed the SQL Type to VARCHAR in the Input link of the transformer stage, it worked.

Thanks
Ramesh