Integer to decimal and then 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
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Integer to decimal and then to integer

Post by highpoint »

I have couple of questions on Integer to Decimal and decimal to integer.

I know decimal (5,2) represents 3 digits before decimal point and 2 digtits after the decimal point.
so total is 5.


In case of Integer(5) it seems to hold more than 5 digits. I would like to understand the concept of small int, integer with different values and big int.
What values it can hold. Please explain or point me to some documentation specifically in regards to datastage.


Also I noticed when the database (DB2) has column definition as integer(4) why does datastage takes it as integer(10) during table definition import.


Also during coding i have source column as integer(10) when i move through the aggregator i converted it to decimal(10,0) and then later on converted decimal(10,0) to integer(10) in a transformer with out using any functions i.e implicit conversion by datastage. In this method am i truncating any data.
Note: I want the data in the final output as 1 not like 0001. I would like to do this using transformer unless its absolutley neccessary.
I have checked DS forums could find anything helpful.


And also i have a suggestion for DSXchange forums.

Like if i have a question which was asked earlier by someone else then the other users reply back saying use search.

And when you search say you find 25 topics related. And in 24 of them it will be written to do search. So a person has to go through 24 not-needed forums to get to the right one.

Can we have some special tag or something to find this answered one. So, that it saves time of going to unnceccary topics.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Precision will be ignored for Integer, SmallInt and TinyInt data types.
Integer (int32) can be up to 2**31-1 so can have at most ten digits plus a sign. SmallInt (int16) can be up to 2**15-1 so can have at most five digits plus a sign. TinyInt (int8) can be up to 2**7-1, or 127, so can have at most three digits plus a sign.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

Would appreciate reply to my remaining questions please
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

INTEGER(4) in DB2 means four bytes, or 32 bits, or int32. It's not the number of digits.

DataStage always adds nonsignificant leading and trailing zeroes to decimal data to prove that precision and scale are being honoured. You don't get a choice on this. To remove them you can convert to string data type.
If the target data type is integer, try arithmetic (such as adding zero).

I am only a poster, so can not address your suggestion for the site. However I might point out that there is a Site/Forum forum in which suggestions for the site can be posted. You might recommend that the site maintainers look at DeveloperWorks, which does have the ability to tag a post as a question and (if I recall correctly) as an answer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Be patient...answers will come as people can answer them.

DB2 Integer(4) vs DS Integer(10): DB2 is showing you the length of the integer in bytes (4 bytes=32 bits). DS is showing you the precision of the integer, which for 4 bytes is 10 digits. However, as Ray mentioned, the precision is effectively ignored for the various integer types.

Truncating data in your example? Probably not, but it depends on what you've done in the aggregator...can the result of the aggregation be larger than a 10-digit integer?

Final Output: What is your final output going to? A Sequential File, Database table, dataset? What about the datatype for the column? What's it coming from and what's it going into?
In addition to datatype conversions in transformer, you can use the In_format, Out_format and C_format options available under the Format Tab (for Numeric types Integer and Float) in SeqFile and Column Import/Export, or Meta Data editor for the individual columns in those same stages.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Re: Integer to decimal and then to integer

Post by BI-RMA »

highpoint wrote:Can we have some special tag or something to find this answered one.
You mean: an addititional tag to the the "Resolved" and "Workaround" flags?

Of course: this requires the posters asking questions to tag their answered posts. I am afraid, we will all have to discipline ourselves in that respect...
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
Post Reply