I not family with PL/SQL. Can anyone explain why I can't do the following?
BEGIN
IF TRUE THEN
CREATE INDEX TestIndex ON SomeTable (SomeColumn);
END IF;
END;
I would get the following error:
Error report: ORA-06550: line 3, column 5: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
The only way I can by pass this error is do dynamic sql:
BEGIN
IF TRUE THEN
EXECUTE IMMEDIATE 'CREATE INDEX TestIndex ON SomeTable (SomeColumn)';
END IF;
END;