Convert Char 10 to Integer 10 gives unexpected results
Moderators: chulett, rschirm, roy
Convert Char 10 to Integer 10 gives unexpected results
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
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
Re: Convert Char 10 to Integer 10 gives unexpected results
Try to use CAST / CONVERT in query level
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
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>
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>
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
Re: Convert Char 10 to Integer 10 gives unexpected results
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)lpadrta wrote:I am trying to make the SQL db target integer 10 value 3600000008
- Zulfi
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.