Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.
Moderators: chulett , rschirm , roy
hemanthakumar
Participant
Posts: 34 Joined: Mon May 05, 2008 1:31 am
Post
by hemanthakumar » Tue Aug 31, 2010 6:33 am
Hi,
i have following requirement.
If the value contains "-" then use the last three characters of the string else use the whole string.
ex: 1) customer_usa output is usa
2) india output is india.
Any one can help me to resolve for the same.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Aug 31, 2010 6:38 am
Index() would find the position of the "-" and then you conditionally substring off everthing after it. Or not.
-craig
"You can never have too many knives" -- Logan Nine Fingers
HariK
Participant
Posts: 68 Joined: Thu May 17, 2007 1:50 am
Post
by HariK » Tue Aug 31, 2010 6:41 am
Assuming only one instance of '_' occurs and you need only last three characters.
If index(column_name,'_',1) > 0 Then right(column_name,3)
Else column_name
hemanthakumar
Participant
Posts: 34 Joined: Mon May 05, 2008 1:31 am
Post
by hemanthakumar » Tue Aug 31, 2010 6:48 am
i applied the logic, but its giving wrong result.
Thanks for your response.
hemanthakumar
Participant
Posts: 34 Joined: Mon May 05, 2008 1:31 am
Post
by hemanthakumar » Tue Aug 31, 2010 6:53 am
Hi,
i have following requirement.
If the value contains "-" then use the last three characters of the string else use the whole string.
ex: 1) customer-usa output is usa ( corrected the delimiter)
2) india output is india.
Any one can help me to resolve for the same.
HariK
Participant
Posts: 68 Joined: Thu May 17, 2007 1:50 am
Post
by HariK » Tue Aug 31, 2010 7:02 am
All you have to do is to read posts by Craig or me to get the logic.
hemanthakumar
Participant
Posts: 34 Joined: Mon May 05, 2008 1:31 am
Post
by hemanthakumar » Tue Aug 31, 2010 7:05 am
i used dcount and field functions. Its working fine :D
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Aug 31, 2010 7:16 am
hemanthakumar wrote: i applied the logic, but its giving wrong result.
You'd have to show us how you "applied" it and what results you saw as it should have worked just fine. And, like most things, there are multiple solutions to most problems - dcount and field being one such example.
-craig
"You can never have too many knives" -- Logan Nine Fingers
arunkumarmm
Participant
Posts: 246 Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:
Post
by arunkumarmm » Tue Aug 31, 2010 9:34 am
Or you can try
Code: Select all
If Count(Column,'_') > 0 Then Column[3] Else Column
Arun
hemanthakumar
Participant
Posts: 34 Joined: Mon May 05, 2008 1:31 am
Post
by hemanthakumar » Tue Aug 31, 2010 11:08 pm
Thanks Arun, " If Count(Column,'-') > 0 Then Column[3] Else Column" is also working fine.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Wed Sep 01, 2010 6:56 am
As would the Index() and Right() functions.
-craig
"You can never have too many knives" -- Logan Nine Fingers
agpt
Participant
Posts: 151 Joined: Sun May 16, 2010 12:53 am
Post
by agpt » Thu Sep 02, 2010 11:46 am
arunkumarmm wrote: Or you can try
Code: Select all
If Count(Column,'_') > 0 Then Column[3] Else Column
Hi Arun,
Can you please tell me what Column[3] does here exactly?
agpt
Participant
Posts: 151 Joined: Sun May 16, 2010 12:53 am
Post
by agpt » Thu Sep 02, 2010 11:49 am
hemanthakumar wrote: i used dcount and field functions. Its working fine :D
Hemanth,
Can you please give the exact syntax you used?
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Sep 02, 2010 3:42 pm
agpt wrote: Can you please tell me what Column[3] does here exactly?
Without the starting position, it starts from the end so that means to substring off the
last 3 characters from the string.
-craig
"You can never have too many knives" -- Logan Nine Fingers
agpt
Participant
Posts: 151 Joined: Sun May 16, 2010 12:53 am
Post
by agpt » Thu Sep 02, 2010 10:02 pm
chulett wrote: agpt wrote: Can you please tell me what Column[3] does here exactly?
Without the starting position, it starts from the end so that means to substring off the
last 3 characters from t ...
Hi Chulett... Sorry I couldn't read your whole message but I think I got the answer to my question. Thanks a lot!!!!