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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


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