Author |
Message
|
deveshseena |
Posted: Mon Sep 07, 2009 10:55 pm Post subject: MB6 Exception Handling |
|
|
 Newbie
Joined: 07 May 2007 Posts: 7
|
Hi All,
Kindly any one please let me know why the below code doesn't work for decimal values (for the one highlightened in RED):
IF (decimal_to_convert IS NOT NUMBER) THEN
THROW USER EXCEPTION VALUES('U10001', 'decimal_to_convert in CAST_DEC_2_STR IS NOT NUMBER', decimal_to_convert, precision, scale);
END IF ;
me in resolving this issue for handling the decimal values of format 0.0  _________________ Devesh P
Bangalore |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Mon Sep 07, 2009 11:44 pm Post subject: Re: MB6 Exception Handling |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
deveshseena wrote: |
Kindly any one please let me know why the below code doesn't work for decimal values (for the one highlightened in RED):
|
Explain doesnt work? Throws an exception? Doesnt behave as you expect?
If you do a user trace it will show you line by line what it executes, including the outcome of "IF (decimal_to_convert IS NOT NUMBER)" which may help you determine why "its not working". |
|
Back to top |
|
 |
deveshseena |
Posted: Tue Sep 08, 2009 12:02 am Post subject: |
|
|
 Newbie
Joined: 07 May 2007 Posts: 7
|
Trace provided me the output stating that 0.000 is not number. Hence to get more information about handling the exception, requesting to provide some solution for this. _________________ Devesh P
Bangalore |
|
Back to top |
|
 |
mgk |
Posted: Tue Sep 08, 2009 1:29 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
I noticed a couple of things. Firstly you need to provide more information, namely the dayatype of 'decimal_to_convert' and exactly what information is returned, (post the relevant bits of the user debug trace).
Secondly I noticed that you have specifed a user defined SQLState ('U10001') in the exception that you throw, but it is in the wrong location if you want to catch this exception by its state in a user defined exception HANDLER. It needs to be the second insert as the first is defined to be the SQLCode like this:
THROW USER EXCEPTION VALUES( -1, 'U10001', 'decimal_to_convert in CAST_DEC_2_STR IS NOT NUMBER', decimal_to_convert, precision, scale);
Regards, _________________ 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 |
|
 |
deveshseena |
Posted: Tue Sep 08, 2009 9:16 pm Post subject: |
|
|
 Newbie
Joined: 07 May 2007 Posts: 7
|
CAST ("InputRoot"."MRM".WNISRVR3_APP_DATA.WNISRVR3_SERVICE_APP_NUM[TEMP_APP_COUNT]."WN_LOC_SERVICE"[K]."WN_APRV_TOT_LC_AM" AS DECIMAL(12,3));
After the required statement is being executed the value returned is 0.000 and expected format is 000000000.000. The messages are getting failed after executing the exception handling statement stating that the value "0.000" is not a number.
If we remove the code, then we are able to get the successful response with the expected format. _________________ Devesh P
Bangalore |
|
Back to top |
|
 |
Luke |
Posted: Wed Sep 09, 2009 12:49 am Post subject: |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
deveshseena wrote: |
the value returned is 0.000 and expected format is 000000000.000. |
I think you are confused about the DECIMAL format. The 12,3 indicates precision and scale. Just because precision is 12, doesn't mean it will include meaningless digits (e.g. leading zeros) in the representation of a number. If you want to format something to explicitly display it in a certain format, you need to cast it to a STRING, explicitly stating the format using a pattern. |
|
Back to top |
|
 |
Luke |
Posted: Wed Sep 09, 2009 1:15 am Post subject: Re: MB6 Exception Handling |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
deveshseena wrote: |
IF (decimal_to_convert IS NOT NUMBER) THEN
|
Also, what do you think this statement is doing? I'm not familiar with this particular syntax, please can you explain it?
Thanks |
|
Back to top |
|
 |
|