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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts count contained values of several col... DB2 5
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts convert arbitrary UTC to local (SYD) ... COBOL Programming 1
No new posts variable in library name within a PROC. JCL & VSAM 11
Search our Forums:


Back to Top