VARCHAR TO BIGINT

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
srivalli_b
Participant
Posts: 32
Joined: Tue Dec 20, 2011 8:03 am

VARCHAR TO BIGINT

Post by srivalli_b »

HI,

MY JOB :

TDSTAGE -----> XFM---> TDSTAGE

MY SOUCE COLUMN DATATYPE IS VARCHAR
TARGET COLUMN DATATYPE IS BIGINT

I went through dsxchange forum. some body is telling that no conversion is required.But in my case it is not working.

I want to change the target datatype in datastage level.

Is it right way?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Some body is incorrect. Investigate the StringToDecimal() function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srinivasudatastage
Participant
Posts: 5
Joined: Sun Dec 26, 2010 12:08 am
Location: bangalore

Re: VARCHAR TO BIGINT

Post by srinivasudatastage »

Conversion is not required for your senario.

we can't convert integer to varchar.
adsasad
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: VARCHAR TO BIGINT

Post by chulett »

srinivasudatastage wrote:Conversion is not required for your senario.

we can't convert integer to varchar.
a) yes it is
b) yes you can


ps. they're going the other way (varchar to bigint)
-craig

"You can never have too many knives" -- Logan Nine Fingers
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Re: VARCHAR TO BIGINT

Post by zulfi123786 »

srivalli_b wrote:TDSTAGE -----> XFM---> TDSTAGE

MY SOUCE COLUMN DATATYPE IS VARCHAR
TARGET COLUMN DATATYPE IS BIGINT
use the derivation

Code: Select all

If IsValid("int64",Trim(input.column)) Then Trim(input.column) Else SetNull()
Assuming the invalids should be set to Null.
- Zulfi
srivalli_b
Participant
Posts: 32
Joined: Tue Dec 20, 2011 8:03 am

Post by srivalli_b »

sorry, my target datatype is smallint

source value: 978972
But I am getting in the output= -4,068
Please help us
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

Your Source value is too big to fit in smallint. If you have to store the value then change the data type to integer
- Zulfi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You are getting the "correct" value as far as the computer is concerned. What you are seeing is an example of the condition called arithmetic overflow, where the unsigned number is large enough to turn on the most significant bit, causing the signed number to be represented as negative.

A quick fix for some cases would be to change the target data type to uint16 rather than int16. However 978972 is too big even for uint16. You need at least int32 to store this string as an integer data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply