MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with CAST statement

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Tue Jun 13, 2006 10:33 am    Post subject: Help with CAST statement Reply with quote

Hi ,
I've the following values in 3 columns

column definitions:

A DECIMAL(17, 2) NOT NULL
B DECIMAL(17, 2) NOT NULL
C DECIMAL(15, 8 ) NOT NULL

column values:

A B C
.00 999989990000000.01 1.00000000
.00 999989990000000.01 1.00000000

IN 2 ROWS

i get an sqlcode 802 on this sql.can u help me what I need to here to get the final value .

Code:
SELECT SUM( CAST ( ( A + B  )
                 * ( C) AS DECIMAL(17, 2)
                              )                                     
                  )                                           
 INTO  :W-AMT :W-NULL-VALUE                       
w-amt S9(15)V9(02) COMP-3.

Thanks,
vijay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jun 13, 2006 10:47 am    Post subject: Reply with quote

vijay,

If your intention is to use only 2 decimals then you need to cast column C with 2 decimals instead of 8.

try this sql
Code:

SELECT (A + B) * CAST((C) AS DECIMAL(7,2))   
  FROM TABLE;                                             


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Tue Jun 13, 2006 11:11 am    Post subject: Reply with quote

thanks kolusu.it worked
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group