View previous topic :: View next topic
|
Author |
Message |
dsivtina
New User
Joined: 05 Feb 2008 Posts: 5 Location: chennai
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dsivtina
New User
Joined: 05 Feb 2008 Posts: 5 Location: chennai
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
|