ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » [Solved]CAST CHAR to DECIMAL

Post new topic  Reply to topic
 [Solved]CAST CHAR to DECIMAL « View previous topic :: View next topic » 
Author Message
billybong
PostPosted: Thu Apr 19, 2007 8:25 am    Post subject: [Solved]CAST CHAR to DECIMAL Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

Hi all!

Could someone have a look at this and advice me why this does not work?

DECLARE price_pattern CHARACTER '#.##0,00';

SET OutputRoot.MRM.products.item[i].price = CAST('64,34' AS DECIMAL FORMAT price_pattern DEFAULT 0.00);

The price element becomes the default value, I've tried changing it to confirm it.
Is something wrong with my pattern?
_________________
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower


Last edited by billybong on Fri Apr 20, 2007 12:49 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
vsr
PostPosted: Thu Apr 19, 2007 10:09 am    Post subject: Reply with quote

Centurion

Joined: 04 Apr 2006
Posts: 104

It should work if you use colan after DEFAULT in your statement. That is DEFAULT '0.00' instead of DEFAULT 0.00 .

We should cast the same types , here CHARACTER .

0.00 is of type DECIMAL not CHARACTER .

Apart from that your statement if OK to me !
Back to top
View user's profile Send private message
billybong
PostPosted: Thu Apr 19, 2007 11:41 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

Thanks for your quick answer, even though it was a wrong one.

The default value must be of the same type as the datatype you are casting TO, since no casting is done if the default value is used as a resort instead of throwing an exception. The default value should never fail, and does not use the pattern specified.

I'm still having problems with this, anyone who sees something I've missed?
According to the exception list created if I omit the default value the cast complains about a "grouping separator after decimal".

Could this have something to do with the fact that '#,##0.00' is a more recoqnized pattern than my '#.##0,00' ?

Code:
[Exception List]

(
  (0x01000000):RecoverableException = (
    (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\PluginInterface\ImbJniNode.cpp'
    (0x03000000):Line                 = 926
    (0x03000000):Function             = 'ImbJniNode::evaluate'
    (0x03000000):Type                 = 'ComIbmJniNode'
    (0x03000000):Name                 = 'EnjoyITPriceParserMsgFlow#FCMComposite_1_1'
    (0x03000000):Label                = 'EnjoyITPriceParserMsgFlow.magirus'
    (0x03000000):Catalog              = 'BIPv600'
    (0x03000000):Severity             = 3
    (0x03000000):Number               = 2230
    (0x03000000):Text                 = 'Caught exception and rethrowing'
    (0x01000000):RecoverableException = (
      (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\ImbComputeNode.cpp'
      (0x03000000):Line                 = 464
      (0x03000000):Function             = 'ImbComputeNode::evaluate'
      (0x03000000):Type                 = 'ComIbmComputeNode'
      (0x03000000):Name                 = 'EnjoyITPriceParserMsgFlow#FCMComposite_1_5'
      (0x03000000):Label                = 'EnjoyITPriceParserMsgFlow.TransformToEnjoyItList'
      (0x03000000):Catalog              = 'BIPv600'
      (0x03000000):Severity             = 3
      (0x03000000):Number               = 2230
      (0x03000000):Text                 = 'Caught exception and rethrowing'
      (0x01000000):RecoverableException = (
        (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp'
        (0x03000000):Line                 = 589
        (0x03000000):Function             = 'SqlStatementGroup::execute'
        (0x03000000):Type                 = 'ComIbmComputeNode'
        (0x03000000):Name                 = 'EnjoyITPriceParserMsgFlow#FCMComposite_1_5'
        (0x03000000):Label                = 'EnjoyITPriceParserMsgFlow.TransformToEnjoyItList'
        (0x03000000):Catalog              = 'BIPv600'
        (0x03000000):Severity             = 3
        (0x03000000):Number               = 2488
        (0x03000000):Text                 = 'Error detected, rethrowing'
        (0x01000000):Insert               = (
          (0x03000000):Type = 5
          (0x03000000):Text = '.EnjoyITPriceParserMsgFlow_TransformToEnjoyItList.Main'
        )
        (0x01000000):Insert               = (
          (0x03000000):Type = 5
          (0x03000000):Text = '4.3'
        )
        (0x01000000):Insert               = (
          (0x03000000):Type = 5
          (0x03000000):Text = 'MapMagirusToEnjoyIT();'
        )
        (0x01000000):RecoverableException = (
          (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\ImbRdl\ImbRdlRoutine.cpp'
          (0x03000000):Line                 = 548
          (0x03000000):Function             = 'SqlRoutine::invoke'
          (0x03000000):Type                 = 'ComIbmComputeNode'
          (0x03000000):Name                 = 'EnjoyITPriceParserMsgFlow#FCMComposite_1_5'
          (0x03000000):Label                = 'EnjoyITPriceParserMsgFlow.TransformToEnjoyItList'
          (0x03000000):Catalog              = 'BIPv600'
          (0x03000000):Severity             = 3
          (0x03000000):Number               = 2934
          (0x03000000):Text                 = 'Error occured in procedure'
          (0x01000000):Insert               = (
            (0x03000000):Type = 5
            (0x03000000):Text = 'MapMagirusToEnjoyIT'
          )
          (0x01000000):RecoverableException = (
            (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp'
            (0x03000000):Line                 = 589
            (0x03000000):Function             = 'SqlStatementGroup::execute'
            (0x03000000):Type                 = 'ComIbmComputeNode'
            (0x03000000):Name                 = 'EnjoyITPriceParserMsgFlow#FCMComposite_1_5'
            (0x03000000):Label                = 'EnjoyITPriceParserMsgFlow.TransformToEnjoyItList'
            (0x03000000):Catalog              = 'BIPv600'
            (0x03000000):Severity             = 3
            (0x03000000):Number               = 2488
            (0x03000000):Text                 = 'Error detected, rethrowing'
            (0x01000000):Insert               = (
              (0x03000000):Type = 5
              (0x03000000):Text = '.EnjoyITPriceParserMsgFlow_TransformToEnjoyItList.MapMagirusToEnjoyIT'
            )
            (0x01000000):Insert               = (
              (0x03000000):Type = 5
              (0x03000000):Text = '26.5'
            )
            (0x01000000):Insert               = (
              (0x03000000):Type = 5
              (0x03000000):Text = 'SET OutputRoot.MRM.products.item[i].price = CAST('64,34' AS DECIMAL FORMAT price_pattern);'
            )
            (0x01000000):RecoverableException = (
              (0x03000000):File                 = 'F:\build\S600_P\src\DataFlowEngine\ImbRdl\ImbRdlTypeCast.cpp'
              (0x03000000):Line                 = 257
              (0x03000000):Function             = 'SqlTypeCast::evaluate'
              (0x03000000):Type                 = ''
              (0x03000000):Name                 = ''
              (0x03000000):Label                = ''
              (0x03000000):Catalog              = 'BIPv600'
              (0x03000000):Severity             = 3
              (0x03000000):Number               = 2521
              (0x03000000):Text                 = 'Error while casting'
              (0x01000000):Insert               = (
                (0x03000000):Type = 5
                (0x03000000):Text = '.EnjoyITPriceParserMsgFlow_TransformToEnjoyItList.MapMagirusToEnjoyIT'
              )
              (0x01000000):Insert               = (
                (0x03000000):Type = 5
                (0x03000000):Text = '26.49'
              )
              (0x01000000):Insert               = (
                (0x03000000):Type = 5
                (0x03000000):Text = ''64,34''
              )
              (0x01000000):Insert               = (
                (0x03000000):Type = 5
                (0x03000000):Text = 'DECIMAL'
              )
              (0x01000000):RecoverableException = (
                (0x03000000):File     = 'F:\build\S600_P\src\CommonServices\ImbNumberFormatter.cpp'
                (0x03000000):Line     = 427
                (0x03000000):Function = 'ImbNumberFormatter::parsePattern'
                (0x03000000):Type     = ''
                (0x03000000):Name     = ''
                (0x03000000):Label    = ''
                (0x03000000):Catalog  = 'BIPv600'
                (0x03000000):Severity = 3
                (0x03000000):Number   = 3207
                (0x03000000):Text     = 'grouping separator after decimal'
                (0x01000000):Insert   = (
                  (0x03000000):Type = 5
                  (0x03000000):Text = '#.##0,00'
                )
                (0x01000000):Insert   = (
                  (0x03000000):Type = 5
                  (0x03000000):Text = ','
                )
              )
            )
          )
        )
      )
    )
  )
)


_________________
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower
Back to top
View user's profile Send private message Visit poster's website
billybong
PostPosted: Fri Apr 20, 2007 12:47 am    Post subject: Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

Solved it!

The pattern was:

Code:

DECLARE price_pattern CHARACTER ###,###,##0.00:groupsep=.:decsep=,';


Since my group and decimal separators are reversed I had to point them out in the pattern.

Didn't see anything about the groupsep and decsep except in one (!) example code which didnt even explain anything about them.
_________________
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » [Solved]CAST CHAR to DECIMAL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.