IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to fix the issue for SQLCODE -802 and sqlstate 22003


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Khwairakpam Raju Singh

New User


Joined: 05 Dec 2007
Posts: 29
Location: Bangalore

PostPosted: Tue Sep 07, 2010 5:41 pm
Reply with quote

HI,
I have a column COL_A in DB2 which is defined as INTEGER of length(4). I want to run follwoing query to get the sum of this column( amount). Eg:

Select sum(Col_A) from tab_A

If i ran the same query which have less data, its working fine but if I tried to run this query which have huge no of rows, I am getting
SQLCODE =-802 and SQLstate= 22003.

Looks like, the output results exceed the boundary of bytes that a integer field can hold. Is there any other way to fix this issue without changing the fields attributes of Col_A.

Thanks in advance
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 07, 2010 5:48 pm
Reply with quote

Quote:
...defined as INTEGER of length(4)...


why do posters try to impress us with their wealth of knowledge
when it is just useless facts?

the number of bytes a column contains is only worthwhile consideration when referring to character data.
numeric data types require knowledge of capacity - max value.

have not tested it, but it would seem to me that if you were to CAST COL_A as BIG INTEGER and then SUM, it may work.
Back to top
View user's profile Send private message
Khwairakpam Raju Singh

New User


Joined: 05 Dec 2007
Posts: 29
Location: Bangalore

PostPosted: Tue Sep 07, 2010 6:22 pm
Reply with quote

Wow its working with

Select sum(cast((Col_A) as dec(16,2))) from Tab_A

Dick, thanks a lot for your help :-)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 07, 2010 6:29 pm
Reply with quote

glad you were able to overlook my criticism and find a workable solution.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts Facing ABM3 issue! CICS 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top