Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts XMITIP sends it out. Can it copy on l... Rommel Dayon Rustia IBM Tools 0 Tue Sep 05, 2017 10:16 am
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us