Extracting the data after zero

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
saj
Participant
Posts: 30
Joined: Fri Aug 28, 2009 6:00 am

Extracting the data after zero

Post by saj »

Hi All ,

I have a requirment to extract the data that comes after 0 .

ex: EM0000000000000592176

Need to fetch 592176

The number of zeros may vary

ex:EM00789892

Output :789892

When we try with Field(Arg1,"0",1) this will provide EM .
Please let me know how to get data after 0
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Assuming that the string will always have at least one zero:

Code: Select all

Trim(Field(Arg1,'0',2,999),'0','L')
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Is the target column a string?

Hmmm... I think the leading "EM" is going to negate your approach, Arnd.

I was thinking you could find the first '0' starting from the back and then substring from there but zeroes in the number itself would hork that up. Seems you might need to find the first zero, then start from there to find the first non-zero and take from there to the end.

Or remove all of the non-numerics (the 'double convert' comes to mind) and then strip the leading zeroes. I'm sure there are other ways to skin this cat.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Arnd's approach is totally valid.

This is a server job, so data type conversion will be automatic.

Another solution is DIGITS(InLink.TheString) + 0 (performing any arithmetic removes leading zeroes).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ray.wurlod wrote:Arnd's approach is totally valid.
Ah, true. Was reading it kind of... bass ackwards. Just to amend it slightly, I would say "Assuming that the string will always have at least one leading zero". :wink:
-craig

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