Page 1 of 1

Check for a numeric

Posted: Wed Jan 11, 2012 10:41 pm
by phanikumar
I have a filed called Phone_No where in I need to check whether the incoming data is numeric or not.Can some one let me know how to do this validation to find out if it is a numeric field or not.

Regards

Kumar

Re: Check for a numeric

Posted: Wed Jan 11, 2012 10:54 pm
by SURA
Cant you use NUMS funcation?

DS User

Posted: Wed Jan 11, 2012 11:08 pm
by phanikumar
Can someone tell me how to use the num function to find out if all the fields from the source are numeric

Posted: Wed Jan 11, 2012 11:13 pm
by SURA
Num (col).

You can see the example in your help.

DS User

Posted: Wed Jan 11, 2012 11:24 pm
by ray.wurlod
What is the data type of the incoming field? For example if it is int32 or decimal, you don't need to check - it can not but be numeric.

Posted: Thu Jan 12, 2012 12:20 am
by pandeesh
Either you can use Num() or the below old technique:

Code: Select all

if len(Convert("0123456789","",YourField))=0 then numeric else non-numeric

Posted: Thu Jan 12, 2012 1:15 am
by kmsekhar
As suggested by Ray if the incoming data is not (Int32,Decimal) datatype then another way to check for numeric data

Code: Select all

If IsValid("int32", InputColumn) Then "Int" Else "Var"

Posted: Thu Jan 12, 2012 4:23 am
by chandra.shekhar@tcs.com
Or you can use this one too 8)

Code: Select all

 If trim(YourColumn) > 0 then 'Valid' else 'Invalid'.

Posted: Thu Jan 12, 2012 3:49 pm
by phanikumar
The data type for this field is coming as varchar and when I use Num(i/pcol)
it is giving me a warning message like null string argument.

Posted: Thu Jan 12, 2012 4:23 pm
by SURA
Num(NullToEmpty(col))

I am not sure how this will work. But give it a go.

When you share the warning, cant you provide the entire warning detail!!

DS User

Posted: Thu Jan 12, 2012 5:30 pm
by phanikumar
I did handle the nulls by doing Null to Empty and used the Num function, it doesn't work.Still come up with warnings.The entire warning message is like null string arguments and I had some thousands of these warnings.

Posted: Thu Jan 12, 2012 6:49 pm
by SURA
In which stage it is giving warning?

Copy and paste the warning.


DS User

Posted: Thu Jan 12, 2012 8:46 pm
by phanikumar
Hi

I fixed this issue by handling the spaces, when I am using Num function previously I was not taking care of spaces. So I did null to Empty(str) = ' ' then i replaced with some value.Hence the problem is solved.Thank you for all your inputs.

Regards

Kumar

Posted: Thu Jan 12, 2012 8:57 pm
by pandeesh
Please resolve the topic, your issue gets resolved.

Thanks