Hi All,
Can anyone please suggest me if there is any replace function in data stage. i could not find it in help. can anyone please suggest me how do i use it in data stage.
Thanks
Mark
replace function
Moderators: chulett, rschirm, roy
Use Multiple Functions to Resolve this
Code: Select all
Left(SourceString, index(SourceString,FindString) - 1) will give the left part of the string
Right(SourceString, Len(SourceString) - (index(SourceString,FindString) + Len (FindString) - 1 )) will give the Right part of the sring
When you combine these both using a : operator with your new string you'll get the desired result
Eg.
SourceString = 'SuperSoulExistsEveryWhere'
FindString = Exists
AddString = OverSees
Left ( 'SuperSoulExistsEveryWhere', 10 - 1) = SuperSoul
Right ('SuperSoulExistsEveryWhere', 25 - ( 10 + 6 - 1) ) = EveryWhere
Ans = SuperSoul : 'OverSees' : EveryWhere
Django
If a simple dsx project requires such intelligence how much more is required to create this Cosmic System. Who dares to say there is no intelligence behind this creation i.e. no GOD .....
If a simple dsx project requires such intelligence how much more is required to create this Cosmic System. Who dares to say there is no intelligence behind this creation i.e. no GOD .....
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 1
- Joined: Tue Mar 12, 2013 2:33 am
- Location: india
Replace a pattern in string
Below is the code of Datastage routine to Replace a pattern in string
Input_String = Arg1
From_String = Arg2
To_String = Arg3
Len_From_String = Len(From_String)
Diff_Len = Len(To_String) - Len(From_String)
Loop_String = Input_String
For i = 1 To Count(Loop_String, From_String)
Loc_old = Index(Loop_String, From_String,i)
If (i<>1) Then Loc = Loc_old + (Diff_Len * (i-1)) Else Loc = Loc_old
Input_String = Left(Input_String, Loc-1) : To_String : Right(Input_String,Len(Input_String) - Loc - Len_From_String + 1)
Next
Ans = Input_String
Input_String = Arg1
From_String = Arg2
To_String = Arg3
Len_From_String = Len(From_String)
Diff_Len = Len(To_String) - Len(From_String)
Loop_String = Input_String
For i = 1 To Count(Loop_String, From_String)
Loc_old = Index(Loop_String, From_String,i)
If (i<>1) Then Loc = Loc_old + (Diff_Len * (i-1)) Else Loc = Loc_old
Input_String = Left(Input_String, Loc-1) : To_String : Right(Input_String,Len(Input_String) - Loc - Len_From_String + 1)
Next
Ans = Input_String
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard, saintankit. Unfortunately a server routine will not serve the original request, which is in a parallel job.
For parallel jobs the routine must be written in C++
For parallel jobs the routine must be written in C++
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 301
- Joined: Thu Jul 14, 2005 10:27 am
- Location: Melbourne, Australia
- Contact:
You probably want to take a look at <a href="viewtopic.php?t=106358&highlight=PXEReplace">this post</a>.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>