MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To find total no: of records in a table space

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
binduvnair
Beginner


Joined: 07 Jan 2003
Posts: 16
Topics: 8

PostPosted: Mon Feb 17, 2003 10:47 pm    Post subject: To find total no: of records in a table space Reply with quote

We had uploaded data to several tables .. Now we want to see the no: of records in a particular db space .. How can we do it ? Note that we have not updated the catalogue .. so we can't get it from the catalogue tables .. But table names can be retrieved from the catalogue tables .. Can any one help me to formulate a query for this?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Feb 18, 2003 2:18 pm    Post subject: Reply with quote

Bindu,

The following JCL will give you the total no: of records for the database in question. A brief explanation of the job.I chose the batch appraoch since the interactive solution may tie up your session.

Step0100 creates the select cards for the next step. In this step we query sysibm.systables for the tables under the particular database.For each table we generate a sql statement like this

Code:

SELECT COUNT(*) AS RECCNT FROM CREATOR.TABLE1   UNION


Here I used creator.table name as that is the standard of our shop. so if you have a different standard then change the control card where it says creator.for ex: if your shop has a standard as DBNAME.TABLENAME

Then in step0100 change the 'CREATOR' to DBNAME

now the step0200 takes in these created control cards and does a sum on the total values.

we need to subtract 1 from the count as we are also including the record count from sysibm.sysdummy1. This has to be used inorder to properly end the sql syntax.

The output from step0100 looks like this

Code:

SELECT COUNT(*) AS RECCNT FROM CREATOR.TABLE1   UNION
SELECT COUNT(*) AS RECCNT FROM CREATOR.TABLE2   UNION
.....

SELECT COUNT(*) AS RECCNT FROM CREATOR.TABLEN   UNION
SELECT COUNT(*) AS RECCNT FROM SYSIBM.SYSDUMMY1) A;



In step0200 we are adding another sql statement for summing all the counts
Code:

SELECT SUM(A.RECCNT) -1 FROM ( 



Code:

//STEP0100 EXEC PGM=IKJEFT01                                       
//*                                                                 
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121                             
//SYSPRINT DD  SYSOUT=*                                             
//SYSTSIN  DD  *                                                   
 DSN SYSTEM(XXXX)                                                   
 RUN  PROGRAM(DSNTIAUL) -                                           
      PLAN(DSNTIAUL)    -                                           
      PARMS('SQL')      -                                           
      LIB('DB2P.RUNLIB.LOAD')                                       
//SYSREC00 DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)
//SYSPUNCH DD SYSOUT=*                                             
//SYSIN    DD  *                                                   
SELECT CHAR('SELECT COUNT(*) AS RECCNT FROM ') CONCAT               
       CHAR(CREATOR)   CONCAT                                       
       CHAR('.')       CONCAT                                       
       CHAR(NAME)      CONCAT                                       
       CHAR(' UNION ') CONCAT                                       
       CHAR('       ')                                             
       FROM                                                         
       SYSIBM.SYSTABLES                                             
       WHERE DBNAME='YOUR DBNAME'
       AND TYPE = 'T'                                         
UNION                                                               
SELECT CHAR('SELECT COUNT(*) AS RECCNT FROM SYSIBM.SYSDUMMY1) A;') 
       FROM                                                         
       SYSIBM.SYSDUMMY1
       ;
                   
//STEP0200 EXEC PGM=IKJEFT01
//*                                       
//SYSTSIN  DD  *                         
 DSN SYSTEM(XXXX)                         
 RUN  PROGRAM(DSNTEP2) -                 
      PLAN(DSNTEP2)    -                 
      LIB('DB2P.RUNLIB.LOAD')             
 END                                     
//*                                       
//SYSTSPRT DD  SYSOUT=*                   
//SYSPRINT DD  SYSOUT=*                   
//SYSIN    DD *                           
  SELECT SUM(A.RECCNT) - 1 FROM (         
//         DD DSN=&T1,DISP=(OLD,PASS)                               
//*


The sysprint dataset will have the count of total records in the database

Hope this helps....

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group