How to read the numeric part of a string in PX

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
Abhijeet
Participant
Posts: 20
Joined: Wed Jul 27, 2005 1:00 am

How to read the numeric part of a string in PX

Post by Abhijeet »

Hi is there any built-in function to read only the numeric characters of a string
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, there are several built-in functions in PX. The one you choose depends upon the stage where you are looking to do this and whether the number is an integer or a floating point one. Please look into you documentation and you can use the search string "from_string" to get some of the functions - or at least find the appropriate starting point.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar
Abhijeet
Participant
Posts: 20
Joined: Wed Jul 27, 2005 1:00 am

Post by Abhijeet »

the "from_string" functions convert numeric string to decimal/float .
String_to_decimal or decimal_from_string function returns me 0.0 on a alphanumeric string.

Whereas i want to extract all the numeric characters from a alphanumeric string.

Eg: string-> 123fre233

should return me 123 {numeric characters until first non-numeric character is encountered.}
Here 233 is discarded.
Abhijeet
Participant
Posts: 20
Joined: Wed Jul 27, 2005 1:00 am

Post by Abhijeet »

kumar_s wrote:Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar
Hi kumar ,

The input string can have alphanumeric , whitespaces and symbols . Out of this I have to extract only the numeric part. So in such case using convert func wont be feasible. :(
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Abhijeet wrote:Whereas i want to extract all the numeric characters from a alphanumeric string.

Eg: string-> 123fre233

should return me 123 {numeric characters until first non-numeric character is encountered.}
Just wanted to point out that 'all numeric characters' and 'numeric characters until the first non-numeric character' are two totally different things. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Abhijeet
Participant
Posts: 20
Joined: Wed Jul 27, 2005 1:00 am

Post by Abhijeet »

True, lets stick to extracting all numeric characters from a string . :)
So is it possible in PX without me writing any routines ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Abhijeet,

no, there is no builtin function in PX to do what you want.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Abhijeet wrote:
kumar_s wrote:Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar
Hi kumar ,

The input string can have alphanumeric , whitespaces and symbols . Out of this I have to extract only the numeric part. So in such case using convert func wont be feasible. :(
Hi,
Yes it may be feasible if you convert all the alpahabets,whitespace,symbols to space and use FIELD funciton to locate the first Space. Or trim all space and convert to numeric.

-Kumar
Post Reply