Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ideas

New User


Joined: 25 May 2005
Posts: 53
Location: India

PostPosted: Tue Apr 25, 2006 2:26 pm    Post subject: How to move the value of Count(*) to a local variable
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: 171
Location: Bangalore

PostPosted: Tue Apr 25, 2006 2:40 pm    Post subject:
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: 53
Location: India

PostPosted: Tue Apr 25, 2006 2:49 pm    Post subject:
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    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 CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us