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 

SELECT COUNT(*) failing with -802 SQLCODE

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


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Fri Dec 14, 2007 12:19 pm    Post subject: SELECT COUNT(*) failing with -802 SQLCODE Reply with quote

One of our developers is running a DSNTEP2 job to determine the number of rows on a production table.

He is getting a -802 error, which leads me to believe that it is because the number of rows on the table exceeds the highest allowable number for an integer type value (I believe a COUNT(*) returns an integer).

I know from past RUNSTATS that there were over 2 billion rows on this table on an earlier date. What type of SQL can be written to determine
the count of rows on this table?

Note: I am trying SELECT DECIMAL(COUNT(*)) from THE_TABLE, but I'm not sure it won't return an error again.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Dec 14, 2007 12:29 pm    Post subject: Reply with quote

I don't think that will work. Try COUNT_BIG(*). COUNT_BIG returns a DECIMAL(31,0).
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Dec 14, 2007 12:32 pm    Post subject: Reply with quote

jim haire,

Count indeed returns the result as an Integer of 4 bytes which can contain a max value of 2,147,483,647.

However you can use COUNT_BIG which gives you the result in decimal number with precision 31 and scale 0.

Check this link which explains the COUNT_BIG function

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQJ12/3.1.3?DT=20050325102208

Hope this helps...

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


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Mon Dec 17, 2007 8:42 am    Post subject: Reply with quote

Thanks. COUNT_BIG is what I was looking for.
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