Left Zero fill, force to field length

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
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Left Zero fill, force to field length

Post by ulab »

Hi Friends,

Am new to Data stage, am looking for a logic which can fill '0'(zeros) at the left side of the input colomn value, just as below

FromTable, ToColumn, Type, Length, Formating
uniquename, AD-ACCT-ID, 9(12), Numeric, 12, Left Zero fill, force to field length

I have done a search but could not able to find any post, please give me a helping hand
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

define the field as Number and specify the length, it will automatically pad 0's on left to make it of same length.

are you writing to database or a flat file?
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The transform function Right('000000000000':In.AD-ACCT-ID,12) on a string.
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Post by ulab »

ArndW wrote:The transform function Right('000000000000':In.AD-ACCT-ID,12) on a string. ...
from the above statement, this one is not giving the results as expected, but in fact the out put is as below in bold

c1 AD-ACCT-ID c2 c3
@10296505000000 000 000

the bold 8 characters are the output of the field AD-ACCT-ID

yes am writing the output data into a Seq File,
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

what is the datatype you are using for that field?
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Left Zero fill, force to field length

Post by ulab »

ArndW wrote:The transform function Right('000000000000':In.AD-ACCT-ID,12) on a string. ...
from the above statement, this one is not giving the results as expected, but in fact the out put is as below in bold

c1 AD-ACCT-ID c2 c3
@10296505000000 000 000

the bold 8 characters are the output of the field AD-ACCT-ID

yes am writing the output data into a Seq File,
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Re: Left Zero fill, force to field length

Post by ulab »

ulab wrote:
ArndW wrote:The transform function Right('000000000000':In.AD-ACCT-ID,12) on a string. ...
Char data type
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'd bet Char(8) - am I right? So you can only get eight characters in that field.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

When datatype is char, datastage pads the character defined in environment variable. hence the length will be 12 always and the syntax posted by Arnd wont work.

you might like to trim the leading spaces to get the desired result.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Post by ulab »

ray.wurlod wrote:I'd bet Char(8) - am I right? So you can only get eight characters in that field. ...
char(12) on either ends(in source and target as well)
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then perhaps Right('000000000000':Trim(In.AD-ACCT-ID),12) would work.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Post by ulab »

chulett wrote:Then perhaps Right('000000000000':Trim(In.AD-ACCT-ID),12) would work. ...
thanks to all for their time, the problem got resolved with the following logic in the source stage(Oracle DB)

LPAD(supl.uniquename,12,'0') as uniquename

Once again thanks to All :)
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
Post Reply