DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
This topic has been marked "Resolved."
Author Message
horserider
Participant



Joined: 09 Jul 2007
Posts: 71

Points: 878

Post Posted: Fri Dec 02, 2011 4:51 pm Reply with quote    Back to top    

DataStage® Release: 7x
Job Type: Parallel
OS: Unix
I have a string VARCHAR[10]. Here is what is needed

(1) First find out if a string has any numeric digits or not.
(2) If yes, find the first position of the numeric digit.
(3) Also, find what that numeric digit is.

I can find out if a string has numeric or not using Alpha() but for those string that tells me that they do contains some numeric value, how do I find #2 and #3mentioned above?
Mike



Group memberships:
Premium Members

Joined: 03 Mar 2002
Posts: 796
Location: Chicago
Points: 5099

Post Posted: Fri Dec 02, 2011 8:07 pm Reply with quote    Back to top    

Interesting requirement...

Off the top of my head:
1) Custom routine
2) Brute force using 10 index functions and some if-then-else logic
3) Get creative with length and convert functions

If this is a 1-time deal, then I'd just go the brute force route. If it will be a frequent requirement, then I'd go with the custom routine.

Mike
Rate this response:  
Not yet rated
horserider
Participant



Joined: 09 Jul 2007
Posts: 71

Points: 878

Post Posted: Fri Dec 02, 2011 8:10 pm Reply with quote    Back to top    

Even if I plan to use search function (INDEX) 10 times, how to I search for numbers 0-9 in a string. Can this be done in 1 function?
Rate this response:  
Not yet rated
qt_ky



Group memberships:
Premium Members

Joined: 03 Aug 2011
Posts: 1508
Location: USA
Points: 10675

Post Posted: Fri Dec 02, 2011 8:34 pm Reply with quote    Back to top    

You can do it in a Transformer stage, something like this (creative way):

Code:
lnk.col[Index(Convert('1234567890', '##########', lnk.col), '#', 1), 1]


If '#' will ever exist in the input column, then use some other character that is unique instead.

_________________
 
Eric
_________________

Time is nature's way of keeping everything from happening at once.
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 51755
Location: Sydney, Australia
Points: 281034

Post Posted: Sat Dec 03, 2011 3:59 am Reply with quote    Back to top    

If you're prepared to use a BASIC Transformer stage or server job, you could have
Code:
MatchField(InLink.TheString,"0X1N0X",2)
which would answer all three questions.

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Sydney and Melbourne
Rate this response:  
Not yet rated
karthi_gana



Group memberships:
Premium Members

Joined: 28 Apr 2009
Posts: 683

Points: 6228

Post Posted: Wed Mar 28, 2012 4:36 am Reply with quote    Back to top    

I am really curious to know the meaning of 0X1N0X

_________________
Karthik
Rate this response:  
Not yet rated
karthi_gana



Group memberships:
Premium Members

Joined: 28 Apr 2009
Posts: 683

Points: 6228

Post Posted: Wed Mar 28, 2012 4:40 am Reply with quote    Back to top    

I have also seen this on

http://www.pickwiki.com/cgi-bin/wiki.pl?action=browse&diff=1&id=AMVedit_AE

it seems like BASIC SUBROTUINE written in the above link.

_________________
Karthik
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 38859
Location: Denver, CO
Points: 198396

Post Posted: Wed Mar 28, 2012 7:22 am Reply with quote    Back to top    

It's a pattern, the UniVerse equivalent of a regular expression. The MATCH operator is fully explained in the UniVerse BASIC pdf. I don't believe in posting entire chunks of manuals here, so suffi ...

_________________
-craig

"Do unto those downstream as you would have those upstream do unto you."
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 51755
Location: Sydney, Australia
Points: 281034

Post Posted: Wed Mar 28, 2012 3:25 pm Reply with quote    Back to top    

You can read about DataStage BASIC match patterns in, curiously, the DataStage BASIC manual.
Shocked

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Sydney and Melbourne
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 38859
Location: Denver, CO
Points: 198396

Post Posted: Wed Mar 28, 2012 3:26 pm Reply with quote    Back to top    

That too. Wink

_________________
-craig

"Do unto those downstream as you would have those upstream do unto you."
Rate this response:  
Not yet rated
horserider
Participant



Joined: 09 Jul 2007
Posts: 71

Points: 878

Post Posted: Wed Mar 28, 2012 8:55 pm Reply with quote    Back to top    

Index and Convert as proposed worked just fine.
Rate this response:  
Not yet rated
shobhit_vk_gupta
Participant



Joined: 05 May 2010
Posts: 14

Points: 128

Post Posted: Tue Jun 05, 2012 5:54 am Reply with quote    Back to top    

A simple solution which I can suggest but it is in Server Job:

Let Say:

The column name in which you have to perform this logic is X.

In transformer of Server Job you can write the below mentioned transformation:

Oconv(X,'MCN')[1,1]

Above written Oconv function will give all the numerals as a output and then we are picking the first one.

Let me know if it servers the purpose.
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 38859
Location: Denver, CO
Points: 198396

Post Posted: Tue Jun 05, 2012 6:33 am Reply with quote    Back to top    

FYI - the DIGITS transform is a short-cut to that particular OConv function.

_________________
-craig

"Do unto those downstream as you would have those upstream do unto you."
Rate this response:  
Not yet rated
rameshrr3



Group memberships:
Premium Members

Joined: 10 May 2004
Posts: 574
Location: BRENTWOOD, TN
Points: 6338

Post Posted: Tue Jun 05, 2012 10:06 am Reply with quote    Back to top    

The OConv will answer everything except the position , so an Index needs to be used along with it , probably in a different transformer derivation ( Assuming this is for a transformer ! )

Code:
Index(InputString,Oconv(InputString,"MCN")[1,1],1)
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours