Using dynamic table name in db2
问题 Currently in my project development need of generating the record count based on certain criteria where the table names are stored in separate table.For instance say xx table stores the table name under the column name is tableInfo. I've written the stored procedure in such a way that DECLARE FGCURSOR CURSOR FOR SELECT tableInfo FROM xx WHERE col1='PO'; OPEN FGCURSOR; FETCH FROM FGCURSOR INTO FILEGROUPMEM; WHILE SQLCODE <> 100 DO SET COUNTVal = 'SELECT COUNT(*) FROM ' || FILEGROUPMEM || '