Execute For Each Table in PLSQL
问题 I want to the the number of records in all tables that match a specific name criteria. Here is the SQL I built Declare SQLStatement VARCHAR (8000) :=''; BEGIN SELECT 'SELECT COUNT (*) FROM ' || Table_Name || ';' INTO SQLStatement FROM All_Tables WHERE 1=1 AND UPPER (Table_Name) LIKE UPPER ('MSRS%'); IF SQLStatement <> '' THEN EXECUTE IMMEDIATE SQLStatement; END IF; END; / But I get the following error: Error at line 1 ORA-01422: exact fetch returns more than requested number of rows ORA-06512