How do I strip first 2 characters ....

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
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

How do I strip first 2 characters ....

Post by its_me48 »

Hello:

I have a name column and all I want to do is if the first 2 characters in the name start with "SN", I need to strip the first 2 characters and load the name.
I can say something like this...
If LEN(link.NAME_COLUMN, 2) = "SN" Then ..???? not sure how to strip
Else link.NAME_COLUMN.

Please help.

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

Post by chulett »

Use the substring operator to check the first two characters. Basically:

Code: Select all

If link.NAME_COLUMN[1,2] = "SN" 
Combine that with the length check to get everything but the first two if that's what you need:

Code: Select all

link.NAME_COLUMN[3,Len(link.NAME_COLUMN)-2]
Of course, some sanity checks on the total size first may be in order. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post by its_me48 »

Thanks Craig. Works now...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You may prefer the Left() and Right() functions, as being more meaningful to future developers.
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