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

Host variable for Count(*)


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

New User


Joined: 05 Feb 2008
Posts: 5
Location: chennai

PostPosted: Tue Nov 25, 2008 1:30 am
Reply with quote

Hi,
I am declaring a cursor for the foll. query SELECT COUNT(*),DEPTNO from DEPT GROUP BY DEPTNO.
While fetching i don't have a dclgen variable for this COUNT(*) and hence i used a local variable TEMP-COUNT
But when doing like this i am getting an error "UNDEFINED OR UNUSABLE HOST VARIABLE "TEMP-COUNT".
Is there any way to rectify this or do i need to alter my DCLGEN

Thanks
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 25, 2008 1:41 am
Reply with quote

You need to look in the DB2 Maual and find out what COUNT(*) will return and define a host variable to receive that.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Nov 25, 2008 3:15 am
Reply with quote

Hi,

You may try this:

Code:
.
.
.
WS-REC-COUNT  PIC  S9(09) COMP VALUE +0..
.
.
 SELECT COUNT(*) INTO             
         :WS-REC-COUNT       
 FROM Table
WHERE ..
Back to top
View user's profile Send private message
dsivtina

New User


Joined: 05 Feb 2008
Posts: 5
Location: chennai

PostPosted: Tue Nov 25, 2008 7:06 pm
Reply with quote

Thanks for ur quick response. One thing i need to get clarified. Should i use only comp variable for COUNT(*),if so what is the minimum length can i have??
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Nov 26, 2008 2:05 am
Reply with quote

dsivtina wrote:
Thanks for ur quick response. One thing i need to get clarified. Should i use only comp variable for COUNT(*),if so what is the minimum length can i have??
I think you overlooked this
Quote:
You need to look in the DB2 Maual and find out what COUNT(*) will return and define a host variable to receive that.
from Craig.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top