Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 19 Aug 2004 @ 19:18:11 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: How to retrieve tablename and its count dynamically
 
From:   Fred Keiser

Here is a stored procedure I use to load a table which can be queried against:

     REPLACE PROCEDURE lidlbjh.dbrowcnt (IN parma VARCHAR(30))
     BEGIN
           DECLARE hQUERY VARCHAR(150);

           Delete from lidlbjh.Table_Row_Count all;

           FOR DBCURSOR AS C_TABLE CURSOR  FOR

              Select 'Insert into lidlbjh.Table_Row_Count Select ' || ''''
                     || trim(databasename) || '.' || trim(tablename) || ''','
                     || ' Count(*) From ' || trim(databasename) || '.'
                     || trim(tablename) || ';' (Title '') as text
              From dbc.tables
              Where tablekind =  't' and databasename =:parma
              order by tablename

              DO
              SET hQUERY = DBCURSOR.TEXT;

                 CALL DBC.SYSEXECSQL( :hQUERY);

           END FOR;

     END;



     CALL LIDLBJH.DBROWCNT('cpccwa');

     SELECT * FROM LIDLBJH.TaBLe_ROW_COUNT;

Fred Keiser

Informatics Systems Engineering (ISE)



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023