convert Varchar to Integer

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
mandyli
Premium Member
Premium Member
Posts: 898
Joined: Wed May 26, 2004 10:45 pm
Location: Chicago

convert Varchar to Integer

Post by mandyli »

Hi

I would like to convert datatype Varchar to Integer.


Thanks for your help.

Man
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The first thing to observe is that not every VarChar can be converted to Integer, so you probably need to use an IsValid() function to test whether the string you have is a valid integer. That done, there are a couple of ways you could effect the conversion, for example StringToDecimal() with the Decimal data type having a scale of 0, or AsInteger(). Is your VarChar nullable? If so you may also need to handle nulls.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mandyli
Premium Member
Premium Member
Posts: 898
Joined: Wed May 26, 2004 10:45 pm
Location: Chicago

Post by mandyli »

Thanks .

I will do it.

Thanks
Man
Post Reply