Author |
Message
|
broker_new |
Posted: Sat Mar 14, 2009 2:25 pm Post subject: Validate integer and decimals |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Wondering is there an ESQL command to check for a field as integer or decimal. I have tried IS INTEGER but didn't worked. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Mar 14, 2009 3:31 pm Post subject: Re: Validate integer and decimals |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
broker_new wrote: |
Wondering is there an ESQL command to check for a field as integer or decimal. I have tried IS INTEGER but didn't worked. |
Did you compare types? _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Sun Mar 15, 2009 1:51 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
broker_new |
Posted: Sun Mar 15, 2009 4:06 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
DECLARE intDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Int);
DECLARE strDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Str);
DECLARE decDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Dec);
returns 16777216 for all three statements but not INTEGER,CHAR,DECIMAL...
is FIELDTYPE is the correct statement to use? _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Mar 15, 2009 8:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
broker_new wrote: |
DECLARE intDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Int);
DECLARE strDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Str);
DECLARE decDataTye CHARACTER FIELDTYPE(InputRoot.XMLNS.In.Dec);
returns 16777216 for all three statements but not INTEGER,CHAR,DECIMAL...
is FIELDTYPE is the correct statement to use? |
Not quite the way you are doing it.
Can you assign the value of the field to a declared variable of the right type?
If the assignment fails how do you test for that? Hint it will probably look a little bit like when you assign a null value to an INTEGER declared variable....
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Mon Mar 16, 2009 1:43 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please explain why you used FIELDTYPE. |
|
Back to top |
|
 |
HOMETOWN47 |
Posted: Mon Mar 16, 2009 3:26 am Post subject: |
|
|
Apprentice
Joined: 25 Mar 2003 Posts: 34
|
Could you use the CAST function and either set a DEFAULT value to indicate an invalid CAST or declare an exception handler to capture the error (have a look at the CAST help in infocenter).... |
|
Back to top |
|
 |
broker_new |
Posted: Mon Mar 16, 2009 5:08 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Quote: |
Can you assign the value of the field to a declared variable of the right type?
If the assignment fails how do you test for that? Hint it will probably look a little bit like when you assign a null value to an INTEGER declared variable.... |
I realized that there is not a direct function to handle this, i will do it using Java Compute Node. Thanks for your help guys _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Mar 18, 2009 3:32 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
The Java compute node seems like overkill! The previous solution of doing CAST (and handle the resulting error if there is one) sounds more appropriate! |
|
Back to top |
|
 |
broker_new |
Posted: Wed Mar 18, 2009 4:43 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
I agree with you.Thanks for posting.Definitely we can do it, when we told we have to cast our team didn't accept and thought we are making the problem.
and between us.....If we are doing a cast for field type validations for fields over 200 and do you think is this worth of doing it.
The web methods team took over the things from us and they are performing the validations e.t.c. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
mgk |
Posted: Wed Mar 18, 2009 8:34 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hello,
Can you explain why you want to see if a field is an integer or decimal etc? _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
broker_new |
Posted: Wed Mar 18, 2009 9:27 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
We are calling a web service (on Mainframe) from broker for which we are using XMLNS domain. The web service is acting crazy and sending incorrect data.
I think you will recommend me to use MRM for validatingthis, but i would like to validate the data using ESQL... please. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
mgk |
Posted: Wed Mar 18, 2009 10:18 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Well you can use XMLNSC to validate against an xmlschema in 6.1. Also, do not forget that on the wire all XML is just characters... Do you have an example of the data being sent to and from the webservice along with the actual error message? _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
broker_new |
Posted: Wed Mar 18, 2009 11:25 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
though Its a good feature I would like to achieve the following.
When we do a schema level validation broker will throw an exception list which makes sense to us but not to others.
So what i would like to do is check for the datatypes and create a SOAP response and send it to the client( user defined customized error).
like
(Just an example)..
<SOAPFault>
<FaultMessage> XML Validate errors occured: Invalid data occured passed in this element</FaultMessage>
<SOAPFault>
If we use MRM or schema level validations or CAST then we might not get this clear meaningful errors we get only the exceptionlist.
you might ask me to navigate thru the list....i did but it will not be that descriptive like the example does. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
kimbert |
Posted: Wed Mar 18, 2009 3:23 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
How about this:
- Use XMLNSC to parse and validate your XML
- Report all validation errors to the caller in a SOAP fault, and...
- ...detect validation errors which are related to simple type validation, and replace them with a clearer, more meaningful error message.
The advantages of this approach are:
1. You don't have to write the validation code.
2. You get fast, standards-compliant schema validation for free
If the web service has a track record of sending wrong data, you really should be using validation. Next month they might start missing out a tag, or getting a namespace wrong. |
|
Back to top |
|
 |
|