Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6169903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:56:15+00:00 2026-05-23T22:56:15+00:00

I not family with PL/SQL. Can anyone explain why I can’t do the following?

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:56:15+00:00Added an answer on May 23, 2026 at 10:56 pm

    Oracle doesn’t allow DDL in a PL/SQL block as static SQL so you’ve identified the only workaround (well, technically, you could use DBMS_SQL rather than EXECUTE IMMEDIATE but you’d still be dealing with dynamic SQL).

    I don’t know that there is any technical reason that they couldn’t allow DDL in static SQL. But since 99% of the time you shouldn’t be doing DDL in a stored procedure– creating objects is something that would almost exclusively be done when you’re doing a deployment rather than at runtime– forcing people to use dynamic SQL makes developers pause to consider whether they’re really in that 1% of cases where such a thing makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The body background is not displaying in firefox. here is my CSS body{ font-family:Trebuchet
Not ever sure if it can be done, but is it possible to use
Using SQL server 2008. I have a family tree of animals stored in a
I need to create a simple search but I can't afford to use Sphinx.
I have following code in my SQL Server 2008 R2 stored procedure. In that
SQL/PHP query works in PHPmyAdmin but not the site. I notice that many have
Not sure how I can reproduce this one in jsFiddle but I will try
I am not sure what happened to my css font-family that I was using
I'm new in .net Family and i've been looking asp.net webpage and following the
Not crazy about the way Xcode 4.2 has laid out the files on disk.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.