Skip to content
Advertisement

PL/SQL Dynamic SQL : Table name not valid

I’m currently learning PL/SQL. I need to create a PL/SQL block to create a backup of all my tables like this : myTable -> myTable_old.

Here’s what I got right now :

Here’s the error :

I don’t understand why this error is coming up, can someone help me ?

Advertisement

Answer

The issue is that you can not use bind variables for table names; Oracle documentation:

The database uses the values of bind variables exclusively and does not interpret their contents in any way.

You should edit your code to use concatenation instead:

Also, notice that, if not double quoted, object names always are uppercase, so you have to look for t_name || '_OLD' and not t_name || '_old'

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement