Dear All:
I need to create a Stored Procedure that will count the rows of each table in my database, but I can't do it.
I tried with:
DROP PROCEDURE "informix".RowCount
CREATE PROCEDURE "informix".RowCount( ) RETURNING Varchar(50,0), Integer;
DEFINE vTable VARCHAR(50);
DEFINE vRows INTEGER;
FOREACH
SELECT TabName, Tabid
INTO vTable, vTabid
FROM Systables
WHERE Tabid > 99
AND TabType = 'T'
LET vRows = ( SELECT COUNT(*) FROM vTable );
RETURN vTable, vRows WITH RESUME;
END FOREACH;
END PROCEDURE;
EXECUTE PROCEDURE "informix".RowCount()
But it throws me an error saying that vTable is not a database table.
What puzzles me is that if I do the following:
select 'select count(*) from ' || trim( tabname ) || ';' from systables where tabid > 99 and tabtype = 'T' order by 1
It shows me the select count(*) with the name of each table.
It is not feasible for me to use this, since there are more than nine hundred tables.
That's why I need to do it via a Stored Procedure;
I would appreciate it if you could give me a hand.
Oh, by the way, the Informix is a 7.31 TD6
Greetings!
Gustavo
------------------------------
Gustavo Echenique
------------------------------