For some reason, I am trying to use a variable name containing the actual table name in the from clause and it won't allow me. I keep getting the error saying I need to declare the variable I'm using eventhough I've used it in another statement that is not the FROM clause.

Example

SELECT count(col1), sum(col2)
FROM v_table_name;

v_table_name was declared as:

v_tablename VARCHAR2(20);
v_tablename := real_table_name;

Is it not allowed to use variables in the FROM clause or am I missing something here?