Reputation: 5
I learning Pl/SQL and have so problem with EXECUTE IMMEDIATE.
I check this:
CREATE TABLE x(id number(10) );
and this work correctly. Currently i want do it with BEGIN EXECUTE IMMEDIATE;END, try:
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE x(id number(10) );' ;
END
And i have error with 2 messages:
- About symbol ";" was replaced to "end-of-file" to be continue
- That we meet "end-of-file" symbol when it should be "; identity"
How i should correctly do it with BEGIN/EXECUTE IMMEDIATE/END ? Thanks
Upvotes: 0
Views: 104
Reputation: 142705
In dynamic SQL, you don't terminate the statement - remove this semi-colon:
... number(10) );'
^
this
So:
SQL> BEGIN
2 EXECUTE IMMEDIATE 'CREATE TABLE x(id number(10) )' ;
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> desc x
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(10)
SQL>
Upvotes: 2