Convert Char 10 to Integer 10 gives unexpected results

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
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Convert Char 10 to Integer 10 gives unexpected results

Post by lpadrta »

My input is a SQL db column that is char 10 value 3600000008

I am trying to make the SQL db target integer 10 value 3600000008

I've created the correct results when sending output to a peek stage, using this transformation: AsInteger(input)

But when I target the SQL db, I'm getting a result of -694967268

I cannot change the structure of the target table.

I've been wrestling this for a while, and I could use some help. Seems like it should be a simple thing...

Lynda
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Convert Char 10 to Integer 10 gives unexpected results

Post by SURA »

Try to use CAST / CONVERT in query level
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Post by lpadrta »

Thanks for the suggestion, SURA.

I found that I can use the tsql command to CAST the Char column to xml, bigint or sql_variant, none of which seems to be giving me what I need.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

Even convert is not helping you?
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Looks to me like yet another example of overflow, as in your value is too large to be represented in an Integer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

Good point.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Post by lpadrta »

When I tried to view the data using the ODBC stage, using CAST(input) as bigint, I can see the expected value.

When I tried to view the data using CAST(input) as int and with the column defined as int 10, then view the data using the ODBC stage, it warns Maximum integer value exceeded.

If I CAST(substring input,1,10) as int then view the data using the ODBC stage, it warns Maximum integer value exceeded.

If I CAST(substring input,1,9) as int then view the data using the ODBC stage, it shows the data less the 10th digit.

If I CAST(substring input,1,10) as bigint then view the data using the ODBC stage, it shows the data including the 10th digit.

So it seems like a 10 position vchar or char with a value like 1234567890 can't fit into an int10 column.

<corrected the line
If I CAST(substring input,1,9) as bigint
to read
If I CAST(substring input,1,10) as bigint>
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Re: Convert Char 10 to Integer 10 gives unexpected results

Post by zulfi123786 »

lpadrta wrote:I am trying to make the SQL db target integer 10 value 3600000008
check what is the size of integer datatypes on your database and also check if the colum defined is signed or unsigned. even datastage integer cant hold the above value if the column is defined as signed (not unsigned)
- Zulfi
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Post by lpadrta »

The only thing I can see is that the target is integer, length 4, precision 10.
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

in such case it should be a signed column and you dont have an option but to change the datatype to bigint or atleast change it to unsigned if you dont expect negative values

One cant park a truck in a garage designed for a car :wink:
- Zulfi
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Post by lpadrta »

For the time being, the rows that have data too large will have to be rejected until a fix is applied.

Thanks very much for your inputs.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

3600000008 is too big to be a signed Integer. You'll need to make it a BigInt. The largest signed integer is 2147483647, the largest unsigned integer is 4294967295. So even uint32 can not cope with all 10-digit numbers.
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