I would suggest you use a cursor and pass the parameter into the cursor

CREATE OR REPLACE FUNCTION Testing(p_table_name in varchar2) RETURN number IS

DECLARE

cursor my_cursor(c_table_name in varchar2) is
SELECT DISTINCT id FROM c_table_name;

my_cursor_rec mycursor%ROWTYPE;

BEGIN

open cursor my_cursor(p_table_name);
fetch my_cursor into my_cursor_rec;

while my_cursor%FOUND loop
STATEMENTS
end loop;

END

I may have got some syntax wrong but if alot of that makes no sense then ignore it. You may want to try and teach yourself some PL/SQL. It can be extremely useful to you.

The function can only return one value and it looks like your query returns more than one. You could use a procedure to list all the values but the theory behind passing a parameter as a table to use in a query is all in that example.

Hope it might help a bit