replace

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

replace

Post by adams06 »

Hi,

how to replace a leading prefix with 'xyz'

Thanks in advance
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:idea: You might want to give just a wee bit more detail... and an example.
-craig

"You can never have too many knives" -- Logan Nine Fingers
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Re: replace

Post by prabu »

adams06 wrote:Hi,

how to replace a leading prefix with 'xyz'

Thanks in advance

Please do the follwing steps in the same order

1) Open your online datastage help
2)Goto Search
type

Code: Select all

string functions
:wink: :wink:

try to use one or more of the functions listed to achieve your result
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

replace

Post by adams06 »

chulett wrote::idea: You might want to give just a wee bit more detail... and an example.

Here are the examples

B-CDE PASS "NEED TO REPLACE B WITH XYZ"

A-HJU PASS "NEED TO REPLACE A WITH XYZ"

AHJU PASS "NEED TO REPLACE A WITH XYZ"

Thanks in Advance.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

If you mean replace everything in front of the first "-" with something else. I think you have a few choices. One is using the FIELD function. The other is to use the INDEX function and substring notation.

Write a DS Function and test both of these:

Code: Select all

Ans="XYZ":"-":FIELD(Arg1,"-",2,999)
or

Code: Select all

Ans="XYZ":Arg1[INDEX(Arg1,"-",1),LEN(Arg1)]
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And if you mean replace the first character with 'XYZ' - substring.
-craig

"You can never have too many knives" -- Logan Nine Fingers
urshit_1983
Participant
Posts: 73
Joined: Wed Jun 28, 2006 3:27 pm
Location: NJ

Post by urshit_1983 »

Try to make a small sub-routine like:


in1=Arg1
l=len(in)
new=right(in,l-1)
in2="XYZ"
Ans=cats(in2,new)
"Nobody is expert in Everything,
But Everybody is expert in Something."
urshit_1983
Participant
Posts: 73
Joined: Wed Jun 28, 2006 3:27 pm
Location: NJ

Post by urshit_1983 »

Sorry the variable names ....

in1=Arg1
l=len(in1)
new=right(in1,l-1)
in2="XYZ"
Ans=cats(in2,new)

Now its ok.
"Nobody is expert in Everything,
But Everybody is expert in Something."
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

the following can save you a routine call

You can use the following derivation in a transformer Stage variable or output Derivation

Code: Select all

"xyz" : in.col[len(in.col)-1]
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Even shorted derivation:

Code: Select all

"xyz":In.Col[2,99999]
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or:

Code: Select all

"xyz":In.Col[2,Len(In.Col2)]
:wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply