Formatting valus

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
svga
Participant
Posts: 73
Joined: Thu Aug 07, 2008 6:31 am
Location: Syracuse

Formatting valus

Post by svga »

Hi,

I need to format my input value based on the length of the target column.
So the length in the 2nd argument of Fmt function should be a variable.

I assign below value to one of the stage variable.

StageVar1 = '"':StageVar:"'0'R" : '"'

The StageVar is holding the varaible length.

Finally, Im using Fmt function as Fmt("45", StageVar1). But the leading zeros is not getting inserted to the value based on the value of StageVar.

Please help me to acheive this requirment.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Is your target a number ?
svga
Participant
Posts: 73
Joined: Thu Aug 07, 2008 6:31 am
Location: Syracuse

Post by svga »

Yes
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The value or the target field's data type? Your target field will need to be a string in order to retain the leading zeroes you are attempting to put there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
svga
Participant
Posts: 73
Joined: Thu Aug 07, 2008 6:31 am
Location: Syracuse

Post by svga »

Hi,

The target datatype is varchar. Am I using the fmt function correctly?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How can your target column have a variable length? You 'zero pad' and right-align something to a fixed length. Either hard-code the length in the FMT function or explain why you can't.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply