Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Host variable for Count(*)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Host variable for Count(*)
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    Post subject:
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

Senior Member


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

PostPosted: Tue Nov 25, 2008 3:15 am    Post subject:
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    Post subject: Reply to: Host variable for Count(*)
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

Senior Member


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

PostPosted: Wed Nov 26, 2008 2:05 am    Post subject: Re: Reply to: Host variable for Count(*)
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us