Well, no - that's not my problem.
The problem is that I will not know the names of the tables until run-time.
Let me give another (once again, contrived) example, that might explain it a bit better.

Imagine that I have two sets of tables, one a set of transactional records (eg, sales records), and the other a set
of consolidated tables for reporting. So I have a Sales table with attributes for Date/Time, ItemID & Price.

Then I have a set of tables that look like Sales201003, Sales201004, Sales201005, etc - a separate table for each
year/month combination. (This is not the way I would design it - but this is how it is and so I need to deal with it).

The SalesYYYYMM tables have one row per day, per item, along with attributes for the total number sold, and total
revenue.

So I have code that selects records from the Sales table, and then inserts summarised data into the appropriate
SalesYYYYMM tables.
The code I would _like_ to be able to write would look something like this:

But the above won't work because I can't use a placeholder for a table name.
I can work around it easily enough by creating a separate statement handle for each YYYYMM combination.
I'm just not sure what the best approach to that would be.

Oh, and please ignore the fact that it's horrible data base design, and that calculated data is being written back
into the data base. As I said, it's a contrived example that helps to describe my problem.

You could produce and prepare the specific queries as you need them. It would be easy and inefficient to use each statement once. Alternatively you could cache them and reuse them. A hash keyed on the table name to hold the prepared statements or a simple sub to prepare them combined with memoize.

I solved this problem when I had to deal a few dozen tables all with the same format and function each named by a client number determined from input data.
The trick is to use a synonym. Write code for one table using a false table name. Then create a synonym named with your false name. Then alter the synonym to point to the table you need to use when you need to and reuse the bulk of your code.
If the term 'synonym' is not familiar, consider it an alias or a symbolyc link with its own name that represents another object (table?) that may have another name.
I don't know the performance impact of this method but I suspect altering a synonym is pretty cheap next to recompiling your insert statements.
Hope this helps.