attaching zeros on left side.

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
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

attaching zeros on left side.

Post by arnie_nits »

Hi

I need to pad zeros on the left side of a varchar field. e.g:
I have a field called ID with length 6. Now if it is populated with 12,the it should come as 000012 and if 123 is populated then it should come as 000123. Please let me know if it is possible and how to implement........

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

Post by ArndW »

Arnie, this was discussed in another current thread. The VarChar() function to use is PadChar()
reddy.vinod
Participant
Posts: 36
Joined: Mon Jul 16, 2007 3:37 am
Location: USA

Re: attaching zeros on left side.

Post by reddy.vinod »

Hai ,
First u take two stage variables like stg1,stg2 .logic in stage varibles is

stg1=6-len(dslink.input)
stg2=str('0',stg1):dslink.input

Present i have no datastage ,i am sending this logic without checking ,try the logic if u get any problem send it to me.
VINOD
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

ArndW, I doubt if there is any inbuild function called PadChar() available. Did you mean to say PadString()?
That function is not the best fit to this requirement (Left side / Beginning Padding).

Str() function can be used directly without stage variable specification:

Code: Select all

Str("0", 6 - Len(Input.ID)):Input.ID (Trim the input field if required)
ArndW wrote:Arnie, this was discussed in another current thread. The VarChar() function to use is PadChar() ...
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

Post by arnie_nits »

got it...its working....Vinod and Joshy thanks very much......

Regards
Arnie.
Post Reply