validate a char or varchar input string as numeric digits

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
DiscGolfer5000
Participant
Posts: 5
Joined: Thu Jul 29, 2004 1:28 pm
Location: USA

validate a char or varchar input string as numeric digits

Post by DiscGolfer5000 »

Is there a way to validate numeric digit-only string input in a parallel job transformer stage? Each character of the entire string must contain digits 0 through 9 only. Periods, negative signs, or any character outside of the 0..9 range needs to be invalid.

I have tried the Num() function and it fails on a decimal.

I have tried the IsValid("uint32", string) function and it also fails on a decimal such as 12.34.

I do not see any built in function to validate numeric digits only or to specify a range or list of characters that the string must match. Is there a built-in way to do this in a parallel job?

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

Post by ray.wurlod »

Code: Select all

Convert("0123456789", "", InLink.TheString) > ""
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Tejas Pujari
Participant
Posts: 14
Joined: Thu Jul 10, 2008 7:37 am
Location: mumbai

Post by Tejas Pujari »

Hi Ray,

here it will convert any blank space in "0123456789" with the InLink.TheString and that with the single character which will be 1st character of InLink.TheString and then will be compared with "".

I did not get what your are trying to tell.
Can you please explain how the above code works as my understanding may wrong.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It removes all numeric digits from the string and then compares the result to an empty string. If there is more than that left, it's not valid.
-craig

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