how to use substring in transformer

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
austin_316
Participant
Posts: 80
Joined: Fri Aug 21, 2009 7:49 am
Location: India

how to use substring in transformer

Post by austin_316 »

i have a column whose data is like
JOB_ID_NAME=1 or JOB_ID_NAME=12 or JOB_ID_NAME1=1 or JOB_ID_NAME1=112 etc.
i have to get the data which is after '=' from these records like for above records the output shud be 1 or 12 or 1 or 112 .... how can i do that. here the data before and after are dynamic. They are different for each and every row.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Code: Select all

FIELD(In.StringColumn,"=",2)
will give you what is after the '=' and before the next '=' (if present). Is that what you were looking for? If not, please also specify if this is a Server or a PX transform, as Server has additional string manipulation functions which are not present in PX.

(corrected syntax per Craig's hint)
Last edited by ArndW on Wed Jun 02, 2010 2:32 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'd need to post examples of your actual data for anyone to provide more cogent help.

Arnd, your syntax example is... lacking. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
austin_316
Participant
Posts: 80
Joined: Fri Aug 21, 2009 7:49 am
Location: India

Post by austin_316 »

actually i was also thinking on the same lines.but was not sure if i can give it that way...but tried as per ur suggestion and got it...thanks alot :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This would be quite simple as a routine. It needs one input argument (the string to be parsed) and will return a delimited string containing the values found.

Code: Select all

FUNCTION GetValues(aTheString)

If UnAssigned(aTheString) Or IsNull(aTheString)
Then

   Ans = @NULL

End
Else

   TheString = UpCase(aTheString)                        ; * handle "or" or "OR"
   TheString = Ereplace(TheString, " OR ", @VM, -1, 0)   ; * convert to dynamic array
   Values = Fields(TheString, "=", 2, 1)                 ; * extract that which follows "="
   Ans = Trim(Values)

End

RETURN(Ans)
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