Field Function in 8.5

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
monishab
Participant
Posts: 3
Joined: Wed Mar 20, 2013 6:29 am

Field Function in 8.5

Post by monishab »

Hi,
Am a newbie to Datastage and am trying to make use of Filed fucntion to extract the values from a string.
Look for the first forward slash starting from the right of the string and take 4 characters to the left of the forward slash

Example Data:
NTCADTX CAD 3333/ 5930/1 ---- 5930
NTSOLDI EUR 2356/ 0001/24 ---- 0001
NTCADTX USD /478568/123/5930/1 --- 5930

Code: Select all

If IsNotNull(lnk_read_gxm_src.agent) OR Len(TrimLeadingTrailing(lnk_read_gxm_src.agent)<>0) then Right(Field(lnk_read_gxm_src.agent,'/',1) ,4) Else '-1'
Above expression pulls data from First '/' only, can any one help me pulling the correct instance which is values before last '/'.

What would be the correct expression for this ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

To solve this one you need to specify the last field number as the third argument of the Field() function. This is most easily found by counting the delimiter characters - and adding one if you want the very last field.

Code: Select all

Right(Field(lnk_read_gxm_src.agent, "/", Count(lnk_read_gxm_src.agent, "/")), 4)
Last edited by ray.wurlod on Tue Apr 30, 2013 2:02 pm, edited 1 time in total.
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 »

As noted, there can be four arguments passed to the Field function, check the documentation. That optional one would be helpful here.
-craig

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