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

How to move the value of Count(*) to a local variable


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

New User


Joined: 25 May 2005
Posts: 52
Location: India

PostPosted: Tue Apr 25, 2006 2:26 pm
Reply with quote

dear all,

if in a program, we make a query on select Count(*) to know the total # of rows in table..it gives an answer..my query is..how to move the value of this Count to a local variable in a program?

thanks!
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Tue Apr 25, 2006 2:40 pm
Reply with quote

Hi,

If you want to do it in COBOL

Declare a variable in the Working Storage Section

01 W-MISC.
05 W-FETCH-CNTR PIC S9(07) COMP-3


then

EXEC SQL
SELECT COUNT(*)
INTO :W-FETCH-CNTR
FROM Tablename
WHERE Field = Host variable
END-EXEC


I think this answers your question


Corrcet me If I am Wrong

Thanks
Shri
Back to top
View user's profile Send private message
ideas

New User


Joined: 25 May 2005
Posts: 52
Location: India

PostPosted: Tue Apr 25, 2006 2:49 pm
Reply with quote

Thanks!, I will try this. My query doesn't requires a where clause, thus it could be refined as:

EXEC SQL
SELECT COUNT(*)
INTO :W-FETCH-CNTR
FROM Tablename
END-EXEC
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