Problem with trimming the filed value

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
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Problem with trimming the filed value

Post by sshettar »

Hi All,

Well i have an issue here with the trim function.
i have this filed which looks like this 000000000205935. This field is actually the record count fo the file and it is of length 15 . well now i want to get only the actualy record count as in i need to get rid of the zero's which are at the first . well this can be done by doin the usual trim and left function but i need something in general as the record count may vary . that i need the function to pick the actual count after neglecting all zeros ahead of it .

could someone help me with this?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Add 0 to it in a transform stage or TRIM(Column,"0","L")
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 »

If I understood it right. Trim will achieve what your are looking for.

Code: Select all


Trim(In.Column, "0", "L")

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
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 »

Oh!! My slow fingers. Arnd beat me :)
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
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Another option

Code: Select all

fmt(In.Column, "Z")
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Mulitpy it by 1 to get an implict conversion to integer.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Post by sshettar »

Thanks guys. it worked
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Of all the answers given, adding zero requires the fewest CPU cycles and is therefore the most efficient.

Both arithmetic solutions (add zero, multiply by one) rely on the fact that DataStage BASIC always returns the shortest possible character string as its arithmetic result - leading and trailing redundant zeroes are removed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

This too... Int(ColumnName)

Thanks,
Anupam
Post Reply