Value Expression in Job Activity Stage

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
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Value Expression in Job Activity Stage

Post by collabxchange »

I have a sequencer where I am executing a 'ls' command in the execute command stage. It is picking up the right file but I want to parse it's name into a parameter in the job activity stage.

e.g.

The file name coming out of 'ls' command is //host/folder1/folder2/folder3/src_Cust-USA-20140101-1.txt

I want to populate a parameter with the value "src_Cust-USA" in the job activity. Can it be done in a single Ealue Expression?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use the Field() function. Extract the 6th "/" delimited field.
-craig

"You can never have too many knives" -- Logan Nine Fingers
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Post by collabxchange »

If I use,

Field(SRC_FILE_NAME,'/',6,1)
O/P = folder3

Field(SRC_FILE_NAME,'/',7,1)
O/P = src_Cust-USA-20140101-1.txt

But I want it as "src_Cust-USA" only. Is it possible to use 2 Field() functions in a single expression?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes... you can use as many as you need. :wink:

And yes, seventh - I counted incorrectly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Post by collabxchange »

Am I doing something wrong? When I put this expression,

Field(Field(SRC_FILE_NAME,'/',7,1)),'-',1)

it says, "Not enough arguments to function field"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What it really should have said was "too many right parentheses".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Post by collabxchange »

True. That threw me off a bit. Its all good now. Thank you very much!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Don't you actually need it like so?

Code: Select all

Field(Field(SRC_FILE_NAME,'/',7,1),'-',1,2)
-craig

"You can never have too many knives" -- Logan Nine Fingers
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Post by collabxchange »

Thats exactly what I did to make it work. Thanks!
Post Reply