zero not to be truncated

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
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

zero not to be truncated

Post by adityavarma »

Hi,

I have a source file which is fixed width and i am using substring function to fecth the value i.e testcolumn[25,2] and the value in source column (varchar) is '03' and the target is integer(2) field.
In between, the source and target i am using a transfomer stage for transfomations on other columns,but the testcolumn is an direct load

when i load the data to the target dataset, the value been loaded is 3, instead the target should be 03.

The zeros are been truncated before i laod to the target, which should not be the case here.

Can anyone please help me on this.

Regards,
Aditya
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Your target is an integer column and thus, by definition, does not have leading zeros. If you want leading zeroes on displaying an integer column you will need to declare to the output format accordingly.
rohithmuthyala
Participant
Posts: 57
Joined: Wed Oct 21, 2009 4:46 am
Location: India

Post by rohithmuthyala »

Keep the target column as Varchar.May i know what is your final target is it a sequential file...?
If so one can directly populate target column into the sequential file as varchar.
Rohith
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

The target is oracle table and the datatype is integer, so in the target i want the value to be 03
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

'03' is only a displaytype for integers. You can do something like

Code: Select all

SELECT to_char(yourIntField, '00')
FROM yourTable 
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

adityavarma wrote:The target is oracle table and the datatype is integer, so in the target i want the value to be 03
Sorry, but it doesn't really matter that is what you 'want', leading zeroes are not stored in any kind of numeric field. As noted, however, you can make it look the way you want when you extract it with the proper TO_CHAR() conversion and format mask.
-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 »

In Oracle an integer with a value of 3 will be stored as (binary) 00000000000000000000000000000011
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