Archives of the TeradataForum
Message Posted: Thu, 19 Aug 2004 @ 19:18:11 GMT
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)
|