Sql file & block statements
743823Feb 9 2010 — edited Feb 9 2010Hey,
I have an sql file that runs a few create, inserts and drop statements on numerous tables for what I'm working on but I want to add in the following code:
Begin
execute immediate 'create table Msc_EXCEPTIONS ( ROW_ID ROWID, OWNER VARCHAR2(30), TABLE_NAME VARCHAR2(30), CONSTRAINT VARCHAR2(30))';
exception when others then null;
End;
Though when this is added to the file I get a line number, in my case 42, and sqlplus waits for input.
If I remove the begin and end segments and just leave the inner 2 lines I get the following message from sqlplus:
BEGIN immediate 'create table Msc_EXCEPTIONS ( ROW_ID ROWID, OWNER VARCHAR2(30),
TABLE_NAME VARCHAR2(30), CONSTRAINT VARCHAR2(30))'; END;
*
ERROR at line 1:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "create table Msc_EXCEPTIONS ( ROW_ID ROWID,
OWNER VARCHAR2(30), " when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "create table Msc_EXCEPTIONS ( ROW_ID
ROWID, OWNER VARCHAR2(30), " to continue.
SP2-0734: unknown command beginning "exception ..." - rest of line ignored.
How would I successfully implement that statement in an sql script?