Extract data from a Database Field

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

Dsnew
Participant
Posts: 90
Joined: Tue Apr 19, 2005 2:08 pm

Post by Dsnew »

Ray,

Thanks for the constant support. We get 1 again. Probably because both Stairand airhave a trailing "+" in them :(

Code: Select all

TEST #1
*******
 
Arg1 = Stair+1;air+2;
Arg2 = air
 
Test completed.
 

Result = 1 
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That is the limitation of which I spoke. To avoid it you need to prefix each substring with some other character, such as tilde in the following example.

Code: Select all

FUNCTION ReturnSecondOfPair(aString, aSearchString) 

* Convert string into dynamic array and prefix each substring with tilde. 
String = Convert(";", @FM, aString) 
String = Cats(Reuse("~"), String)
SearchString = "~" : aSearchString : "+" 

* Find search string within string 
FindStr SearchString In String Setting FMC,VMC,SMC 
Then 
   Ans = Field(String<FMC>, "+", 2, 1) 
End 
Else 
   Ans = "" 
End 

RETURN(Ans) 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Dsnew
Participant
Posts: 90
Joined: Tue Apr 19, 2005 2:08 pm

Post by Dsnew »

Ray - You are the MAN! Thanks much :D
Post Reply