A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.
Moderators: chulett , rschirm , roy
collabxchange
Premium Member
Posts: 34 Joined: Thu Aug 28, 2014 8:48 pm
Location: United States
Post
by collabxchange » Wed Oct 15, 2014 1:38 pm
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
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Wed Oct 15, 2014 2:09 pm
Use the Field() function. Extract the 6th "/" delimited field.
-craig
"You can never have too many knives" -- Logan Nine Fingers
collabxchange
Premium Member
Posts: 34 Joined: Thu Aug 28, 2014 8:48 pm
Location: United States
Post
by collabxchange » Wed Oct 15, 2014 2:17 pm
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
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Wed Oct 15, 2014 2:20 pm
Yes... you can use as many as you need.
And yes, seventh - I counted incorrectly.
-craig
"You can never have too many knives" -- Logan Nine Fingers
collabxchange
Premium Member
Posts: 34 Joined: Thu Aug 28, 2014 8:48 pm
Location: United States
Post
by collabxchange » Wed Oct 15, 2014 2:24 pm
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 » Wed Oct 15, 2014 3:17 pm
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
Posts: 34 Joined: Thu Aug 28, 2014 8:48 pm
Location: United States
Post
by collabxchange » Wed Oct 15, 2014 3:30 pm
True. That threw me off a bit. Its all good now. Thank you very much!
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Wed Oct 15, 2014 4:36 pm
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
Posts: 34 Joined: Thu Aug 28, 2014 8:48 pm
Location: United States
Post
by collabxchange » Wed Oct 15, 2014 4:51 pm
Thats exactly what I did to make it work. Thanks!