Check for a numeric

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
phanikumar
Participant
Posts: 60
Joined: Tue Sep 20, 2011 10:44 pm
Location: INDIA

Check for a numeric

Post 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
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Check for a numeric

Post by SURA »

Cant you use NUMS funcation?

DS User
phanikumar
Participant
Posts: 60
Joined: Tue Sep 20, 2011 10:44 pm
Location: INDIA

Post by phanikumar »

Can someone tell me how to use the num function to find out if all the fields from the source are numeric
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

Num (col).

You can see the example in your help.

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

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
kmsekhar
Premium Member
Premium Member
Posts: 58
Joined: Fri Apr 16, 2010 12:58 pm
Location: Chn

Post 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"
Thanks,
Sekhar
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

Or you can use this one too 8)

Code: Select all

 If trim(YourColumn) > 0 then 'Valid' else 'Invalid'.
Thanx and Regards,
ETL User
phanikumar
Participant
Posts: 60
Joined: Tue Sep 20, 2011 10:44 pm
Location: INDIA

Post 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.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post 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
phanikumar
Participant
Posts: 60
Joined: Tue Sep 20, 2011 10:44 pm
Location: INDIA

Post 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.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

In which stage it is giving warning?

Copy and paste the warning.


DS User
phanikumar
Participant
Posts: 60
Joined: Tue Sep 20, 2011 10:44 pm
Location: INDIA

Post 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
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Please resolve the topic, your issue gets resolved.

Thanks
pandeeswaran
Post Reply