truncate trailing zeroes

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
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

truncate trailing zeroes

Post by edward_m »

My sequential file looks like ..
col1 col2 col3
1 100100 123
2 200000 234
3 199900 245
4 329800 424
5 345000 125
6 234500 235

I want to convert this file to..
col1 col2 col3
1 1001 123
2 2000 234
3 1999 245
4 3298 424
5 3450 125
6 2345 235

i.e i need to supress last two zeroes in col2 and load into target.
I used the trim(col2,"0","T"),its taken out all trailing zeroes..
Please guide me how to takeout last two zeroes from col2.

Thanks
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Simple answer is to divide your number by 100

Ans = Int(Input_Value/100)

eg. 1. 348500/100 = 3485
2. 87912/100 = 879
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

rasi wrote:Simple answer is to divide your number by 100

Ans = Int(Input_Value/100)

eg. 1. 348500/100 = 3485
2. 87912/100 = 879
Thanks for your quick reply.My column col2 is varchar datatype.
Please guide me ..
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Post by rafidwh »

Try this

Oconv(columnname, " MR2 " )

I hope U will get
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

use this Input_Value[1,Len(Trim(Input_Value))-2]

This will give you the result
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Post by Sunshine2323 »

Hi Edward,

Substrings(Source.Col,1, Len(Source.Col)-2)

Left(Source.Col,Len(Source.Col)-2)

I am sure there are many more ways of achieving the result.
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
raj_konig
Participant
Posts: 67
Joined: Thu Dec 22, 2005 12:27 am

Post by raj_konig »

even a direct substring function will get this.

substring(col2, 1,4)

raj
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Much more simpler would be:

Your derivation becomes:

Code: Select all


col2[1,4]

Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

Thanks a lot for all.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are no actual data types within server jobs. Dividing by 100 was a perfectly valid method. So is substring (or Left() function).
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