Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

ORA-00903: invalid table name

That is because you cannot use bind arguments to pass the names of schema objects to a dynamic SQL statement.
Instead, you must embed parameters in the dynamic string, then pass the names of schema objects to those parameters.

-- e.g.
table_name := 'EXAMPLE';
-- dont use: 
stmt := 'DROP TABLE :name CASCADE CONSTRAINTS';
EXECUTE IMMEDIATE stmt USING table_name;

-- instead use:
stmt := 'DROP TABLE ' || table_name || ' CASCADE CONSTRAINTS';
EXECUTE IMMEDIATE stmt;
-- or
EXECUTE IMMEDIATE 'DROP TABLE ' || table_name || 'CASCADE CONSTRAINTS';

Source: https://docs.oracle.com/cd/B10500_01/appdev.920/a96624/11_dynam.htm#13947
-- (Making Procedures Work on Arbitrarily Named Schema Objects)
 
PREVIOUS NEXT
Tagged: #invalid #table
ADD COMMENT
Topic
Name
4+9 =