Search
 
SCRIPT & CODE EXAMPLE
 

SQL

dynamic sql 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)
Comment

PREVIOUS NEXT
Code Example
Sql :: show columns in sql 
Sql :: sql get month name 
Sql :: t sql get foreign key 
Sql :: set column to not null mysql 
Sql :: show data in table postgres 
Sql :: sql server arabic collation 
Sql :: blob datatype in mysql 
Sql :: how to create new user and database postgresql in ubuntu 
Sql :: sql limit decimal places 
Sql :: select all_source oracle 
Sql :: mysql sort descending 
Sql :: check if table exists oracle 
Sql :: mysql check if not null 
Sql :: truncate statement in sql 
Sql :: how to fetch first 5 characters in sql 
Sql :: oracle show index columns 
Sql :: is mysql and sqlite same 
Sql :: sql trim all spaces 
Sql :: find a column in all tables mysql 
Sql :: start mysql 
Sql :: sql server concat string and int 
Sql :: dateadd in sql 
Sql :: mysql separator 
Sql :: SQL CREATE UNIQUE INDEX for Unique Values 
Sql :: run sql command line download for windows 10 
Sql :: phpmyadmin password root 
Sql :: install squirrel sql ubuntu 
Sql :: sql first 
Sql :: mysql ip address data type 
Sql :: modify column name in sql 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =