Converting Numeric to Varchar

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Converting Numeric to Varchar

Post by jweir »

Hello,

I need to convert a numeric field into a varchar when I am loading into my DB2 target. I have tried the DecimalToString function, but returned blanks. I also got the same result when I tried the Char() function.

I am extracting this field from SAP, which comes as a numeric. But my DB2 target needs to be Varchar.

Any suggestions?

Thanks in advance.
Jweir

--- If strength were all, tiger would not fear scorpion.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Dont use any function. I believe it will convert automatically.
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Post by jweir »

I forgot to mention that in that field, I have padded that numeric value with a zero at the end of it (i.e. 2010). So when I straight pass it, that zero gets dropped.
Jweir

--- If strength were all, tiger would not fear scorpion.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

What is the target datatype and its size
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Post by jweir »

datatype: varchar
size: 4
Jweir

--- If strength were all, tiger would not fear scorpion.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

How are you padding zeros at the end
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Post by jweir »

Ok, apparently there was never a padded zero. The field comes in as 2010, numeric. But when I straight pass it to the varchar target, the last zero is dropped, resulting in 201.
Jweir

--- If strength were all, tiger would not fear scorpion.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

First character in integer is for sign which is a space for positive number. Trim the numeric field and assign to target field
You are the creator of your destiny - Swami Vivekananda
jweir
Participant
Posts: 134
Joined: Wed Aug 04, 2010 12:31 pm

Post by jweir »

Thanks anbu. It worked.
Jweir

--- If strength were all, tiger would not fear scorpion.
Post Reply