Author |
Message
|
Valarouthu Ravikumar |
Posted: Tue Feb 19, 2008 6:34 am Post subject: regd validation |
|
|
Newbie
Joined: 28 Jan 2008 Posts: 9
|
i have a String of 3 characters to be validated of whether containing all digits or not.In case of not all numbers an user generated exception needs to be thrown.
We tried like casting the String to integer.It throws exception in case it is not a number.But i need to handle that exception and throw as user defined exception. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 19, 2008 6:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
akir |
Posted: Wed Feb 20, 2008 10:21 am Post subject: Check String which contains numbers or not ?? |
|
|
 Acolyte
Joined: 28 Jun 2007 Posts: 51
|
Ravi and i have similar issue.
I get a string as input which must contain only numbers else I should throw an user exception.
Ex :'123' is valid
'a12' is invalid
as per Jeff I cannot use trycatch, and also declare handler as STATE is not SQLSTATE in my case.
can any one help me |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 20, 2008 10:30 am Post subject: Re: Check String which contains numbers or not ?? |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
akir wrote: |
declare handler as STATE is not SQLSTATE in my case. |
You can declare a handler for most any ESQL exception.
I'm also not sure why you can't use Try/Catch node for this - but it's been a while since I've played with using it for this kind of thing. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Feb 20, 2008 12:25 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Is this the only field which you are validating? If not, you should consider enabling message validation, In v6.1 XMLNSC validation has minimal impact on performance. In v6 you'll need to use the MRM parser. |
|
Back to top |
|
 |
akir |
Posted: Wed Feb 20, 2008 2:50 pm Post subject: Re: Check String which contains numbers or not ?? |
|
|
 Acolyte
Joined: 28 Jun 2007 Posts: 51
|
jefflowrey wrote: |
akir wrote: |
declare handler as STATE is not SQLSTATE in my case. |
Quote: |
You can declare a handler for most any ESQL exception. |
Can you please give me a sample on that so that I can try.
Quote: |
I'm also not sure why you can't use Try/Catch node for this - but it's been a while since I've played with using it for this kind of thing. |
Its client's requirement that I follow that specification only and handle it with esql only.
For now I have tried and implemented it the hard way like this
CREATE FUNCTION Func_IsNumber(julianDay CHARACTER) RETURNS BOOLEAN
BEGIN
DECLARE listOfDigits CHARACTER ' ,0,1,2,3,4,5,6,7,8,9,';
DECLARE counterValue INTEGER 1;
DECLARE FLAG BOOLEAN TRUE;
--Count is taken till 3 since we get 3 Charcaters only.
WHILE (counterValue <=3) DO
IF (POSITION((SUBSTRING(InputRoot.XML.Message.Value FROM counterValue FOR 1) || ',') IN listOfDigits) = 0) THEN
SET FLAG=(FLAG AND FALSE);
ELSE
SET FLAG=(FLAG AND TRUE);
END IF;
SET counterValue=counterValue+1;
END WHILE;
RETURN FLAG;
END;
|
|
|
Back to top |
|
 |
akir |
Posted: Wed Feb 20, 2008 2:52 pm Post subject: |
|
|
 Acolyte
Joined: 28 Jun 2007 Posts: 51
|
kimbert wrote: |
Is this the only field which you are validating? If not, you should consider enabling message validation, In v6.1 XMLNSC validation has minimal impact on performance. In v6 you'll need to use the MRM parser. |
Iam using MB6.0 and Iam using MRM parser.Iam also validating another field which is also a repeating structure in Input. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 20, 2008 3:20 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
MRM should be validating your field(s) for you. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|