Server function to extract a particular string

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

Post Reply
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Server function to extract a particular string

Post by Aquilis »

Hi all,
I have routine which connects to database and gets the result. My output from the routine looks like:

Code: Select all

Ans = 
SQL*Plus: Release 10.2.0.3.0 - Production on Wed Jun 18 06:43:41 2008

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> 
EMAILID
--------------------------------------------------------------------------------
Aquilis@yahoo.com

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
.
But now i want have only email address like :
Aquilis@yahoo.com

So what would be the Server functions so that i can achieve the required output : "Aquilis@yahoo.com"
I have tried with following function:

Ans=trimF(trim(Field(Field(Output,'>',2),'',1),'-','A'))
but i am able achieve upto :

Code: Select all

Ans = 
EMAILID

Aquilis@yahoo.com

SQL
------

I appreciate if you guyz suggest me any better approach Or suggest me how to remove Line Feed characters "\n".
Aquilis
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How about:

Code: Select all

Ans=Output<14>
Assuming I counted correctly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Could you elaborate more...
Actaully there are some newline cahracters involved in it after firing my function:
Ans=trimF(trim(Field(Field(Output,'>',2),'',1),'-','A')) ..

i want the result which exists in 4th line.
4th line has got my email id which i need to extract.

Thanks..
Aquilis
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I would do this in 2 steps.

Code: Select all

MailAddress = ''
LOCATE '----------' IN Ans SETTING ColumnHeaderPos ELSE ColumnHeaderPos = 0
IF ColumnHeaderPos THEN MailAddress = Ans<ColumnHeaderPos+1>
This would cater for changes in the line position in the future.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, I meant without 'firing your function' - i.e. on the original output. Why not just suppress all of that extra who-ha so all you get is the answer? Your DBA can educate you on the how of that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

I edited my existing routine and without using any datastage functions Some how i managed to get output as shown below :

Code: Select all

Ans=
Aquilis@yahoo.com
now all i need is only emailid part like:

Code: Select all

Ans=Aquilis@yahoo.com
Aquilis
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Somehow? :D

Remove anything from the string you don't want with either Convert or EReplace. Both have been discussed ad nausem here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The "somehow" part makes me nervous... but it seems that you still have a line break, so a derivation of "In.String<2>" should do the trick.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Andrew/Chulet,

with your help ,we are able to do it.
your "In.string<2>" done the magic.
If i would have able to get your "output<14>", that would have only done this magic early.

anyway Thanks in tonnes.
Aquilis
Post Reply