Leading 0's

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

DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Leading 0's

Post by DS_MJ »

Hi there I have a Numeric value in a job that I am trying to trim just the leading zeros for example:


Field1 [Numeric 17,2] = 000000000000000.00

The result I would like would be 0.00

Any ideas?

Thanks
Thanks in advance,
skrakesh
Participant
Posts: 7
Joined: Wed Mar 17, 2004 3:53 am
Contact:

Post by skrakesh »

Use Round Function: Round(field_name,2)

or

Use longint
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

skrakesh wrote:Use Round Function: Round(field_name,2)

or

Use longint
I want to remove the leading 0's.
Thanks in advance,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Check out this post
viewtopic.php?t=101418
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

DSguru2B wrote:Check out this post
viewtopic.php?t=101418

Thanks DS_Guru:

I used the TRIM(COL_NAME,'0','L') removes the leading zeros but then it removes the 0's from the decimal place too.

Example: 00012345.00

Name SQL TYPE LENGTH SCALE
COL_NAME Num 15 2

when I apply TRIM(COL_NAME,'0','L')
I get 12345
I want 12345.00

Any idea...went thru the forum and people talk about Decimal to String format, floors and fab.
Thanks in advance,
bharathappriyan
Participant
Posts: 47
Joined: Fri Sep 23, 2005 6:01 pm

Post by bharathappriyan »

Hi,

Please use Rnd(inputcolumn name) function.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That generates a random number - not, I suspect, what the OP desires!

In server jobs you can simply perform arithmetic (for example add zero to the number) and it returns the shortest possible string. You could then format it to have two decimal places.

In parallel jobs, it is not quite so easy. You can convert the decimal number to a string, use the Field() function to get that part of the string to the left of the decimal place, trim non-significant leading zeroes from that, concatenate the decimal placeholder and its following two digits then convert the resultant string back to decimal.

View Data will, of course, always display the leading zeroes whether they are there or not; that's its way of reporting the precision and scale to you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
panchusrao2656
Charter Member
Charter Member
Posts: 64
Joined: Sat Sep 17, 2005 10:42 am

Post by panchusrao2656 »

what happens if it has a value like 00000000.00, it might end up like .00 when we use Trim("00000000","0","L")
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

When you format it to two decimal places it regains its leading zero. 8)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

ray.wurlod wrote:When you format it to two decimal places it regains its leading zero. 8) ...
Hello ray.wurlod:

Would really appreciate if you could please tell me how to do this in Parallel job. Cause unable to find anything for format under parjdev.pdf or advpx.pdf. The Basic.pdf mentions the fmt() function but am unable to apply it. :?
Thanks in advance,
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Could anyone point out what is wrong with this:

(TRIM(FMT(COL_NAME,"R2"),'0','L')

Example: 00012345.00

Name SQL TYPE LENGTH SCALE
COL_NAME Num 15 2

when I apply TRIM(COL_NAME,'0','L')
I get 12345
I want 12345.00

so use FMT() Function to keep the 2 places of the decimal. However, PX is not accepting the above cmd.
Thanks in advance,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

FMT() us bit available in px
User the basic transformer if you want to use FMT()
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

DSguru2B wrote:FMT() us bit available in px
User the basic transformer if you want to use FMT()
Thanks...but Dont have basic Transformer in DataStage Designer edition 7.5.1.A. Viewed the palette and was unable to find it to add it.
Thanks in advance,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You will find the BASIC Transformer stage in the Stage Types branch of the Repository. It was intended not to put it on the Palette by default, though you can of course customize your Palette.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

ray.wurlod wrote:You will find the BASIC Transformer stage in the Stage Types branch of the Repository. It was intended not to put it on the Palette by default, though you can of course customize your Palette. ...
Thank you ray.wurlod and DSguru2B....was able to add the Basic Transformer from the Stage Types using the customized Palette.

Using : TRIM(Fmt(out_fa003_lsmw.PAR_AMOUNT,"R2"),'0','L') in basic transformer am able to get the result

12345.00

However if the input data is 0000000.00

its returning .00

how do I get 0.00...?
Thanks in advance,
Post Reply