Page 1 of 1

IsValid function

Posted: Wed Jun 19, 2013 1:40 pm
by kpsita
Hi,
I have a source field from file with CHAR10. I need to check if it is a valid integer. I tried using IsValid function. This worked fine non numeric fields, but even for decimal it validates as a valid number. I need to capture other than integer (including decimal) as not a valid numeric field. How do I get this.

Thanks

Re: IsValid function

Posted: Wed Jun 19, 2013 6:41 pm
by SURA
Read this link. Is it how you used the function?

http://pic.dhe.ibm.com/infocenter/iisin ... tions.html

Posted: Thu Jun 20, 2013 10:00 am
by kpsita
Yes I did try IsValid("int8",mylink.mystring). But for valid values like 22222 and some of the decimal values like 1.0222, it is throwing 0.

Thanks,
Amar

Posted: Thu Jun 20, 2013 11:49 am
by mobashshar
Use this code:

Code: Select all

Num(Convert(".","A",mylink.mystring))
This will check mylink.mystring for Numeric Values (0-9) only. If true it will return 1 else 0.

Hope this helps :)

Posted: Thu Jun 20, 2013 4:12 pm
by ray.wurlod
kpsita wrote:Yes I did try IsValid("int8",mylink.mystring). But for valid values like 22222 and some of the decimal values like 1.0222, it is throwing 0.
These are both correct results.
22222 is too large for int8; it can be int16, int32 or int64.
1.0222 simply is not an integer of any kind.