Hi All,
I have a small query. I have a varchar field of length 40. Need to check if any character in that field is numeric. Is there a function to do this in a transformer stage.
....:(
Thanks
Checking if not numeric value
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
Have you investigated the IsValid() function?
(sorry, misread the requirement - never mind)
(sorry, misread the requirement - never mind)
Last edited by chulett on Sun Nov 11, 2007 10:47 pm, edited 1 time in total.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
Yes Chulett I did. I tried using IsValid() function but in vain.
Correct me if I am wrong.
If I have a char value as Str="devi1" then this is a valid char value.
My requirement is to check if a char field has atleast one numeric value in it.
If I say IsValid(StringToDecimal(Str),"Decimal") this would not work as Str is not numeric value completely but one once char in it is '1'
Correct me if I am wrong.
If I have a char value as Str="devi1" then this is a valid char value.
My requirement is to check if a char field has atleast one numeric value in it.
If I say IsValid(StringToDecimal(Str),"Decimal") this would not work as Str is not numeric value completely but one once char in it is '1'
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There's no inbuilt function, and if you wrote your own it would need to check all ten as well. So the extended expression with ten Index() functions is about as good as you're going to get.
If the data volumes are small (say less than a couple of million rows) you might consider using a BASIC Transformer stage, which will give you access to the Oconv() function - you could then test
If the data volumes are small (say less than a couple of million rows) you might consider using a BASIC Transformer stage, which will give you access to the Oconv() function - you could then test
Code: Select all
InLink.TheString = Oconv(InLink.TheString, "MC/N")
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.
You can also convert all the numeric values to a empty string and compare the resultant string length with the orginal string length to find out if there are any numeric values.
The above code returns 1 if there are numeric values and 0 if there are no numeric values in column Col1.
Code: Select all
if Len(in.Col1) = Len(Convert('0123456789','', in.Col1)) then 0 else 1
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
Hi,
Thats an alternative and a shorter one thanks...
Thats an alternative and a shorter one thanks...
Last edited by devidotcom on Tue Nov 13, 2007 12:46 am, edited 1 time in total.