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 5971437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:30:58+00:00 2026-05-22T20:30:58+00:00

Why the semicolon(‘;’) couldn’t place in the CommandText of a OracleCommand when C# Just

  • 0

Why the semicolon(‘;’) couldn’t place in the CommandText of a OracleCommand when C#

Just like below:

string sql = "select * from table1;";
OracleCommand oc = new OracleCommand(sql , con);
oc.CommandType = CommandType.Text;
oc.ExecuteNonQuery();

The result would turn out to be a error.

Why? Can any one tell me the reason?

  • 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-22T20:30:59+00:00Added an answer on May 22, 2026 at 8:30 pm

    In the comments, we’ve worked out the answer for you. Just so you get an official “answer”, here it is from the OracleOverflow site (see below):

    An OracleCommmand can run only 1 sql or plsql statement at a time. There is no need of separating multiple statements.

    The semicolon is part of documentation to divide multiple statements. It is not part of the single DDL statement. For an OracleCommand there is no need to append a semicolon because it can only handle one statement at a time.

    Edit: This was the original link, which is now dead: http://www.oracleoverflow.com/questions/145/running-ddl-through-an-oraclecommand-without-the-semicolon

    Alternative: http://web.archive.org/web/20100806014022/http://www.oracleoverflow.com/questions/145/running-ddl-through-an-oraclecommand-without-the-semicolon

    Question:

    When trying to run a series of DDL commands through an OracleCommand
    object, I get an ORA-00911 ‘invalid character’ error if I include the
    final semicolon, even though this is part of the SQL syntax in the
    documentation. It also means that you can only execute SQL one
    statement at a time, rather than executing a whole SQL script at once,
    which seems very odd to me.

    After googling for a bit, I found that a workaround is to wrap the DDL
    in an EXECUTE IMMEDIATE PL/SQL statement, but again it fails if the
    DDL has a semicolon at the end (apart from PL/SQL create statements,
    which require the semicolon).

    Does anyone know the reason for this behaviour? The semicolon is in
    the syntax documentation, so I would have assumed it is always
    required, but it fails if the semicolon is included…

    Answer here:

    An OracleCommmand can run only 1 sql or plsql statement at a time.
    There is no need of separating multiple statements.

    The semicolon is part of documentation to divide multiple statements.
    It is not part of the single DDL statement. For an OracleCommand there
    is no need to append a semicolon because it can only handle one
    statement at a time.

    ADDED: You can bundle more than one statement into an BEGIN … END;
    Block (yes, this ends with semicolon). But this statements should be
    DML, DDL or PL/SQL function calls. You cannot bundle multiple SELECT
    statements into an BEGIN … END; Block.

    Comments:

    Why OracleCommand has this limitation of only being able to run 1 statement at a time?

    It’s based on DbCommand specification in ADO.Net. It’s not a limitation of OracleCommand only.

    SqlCommand allows multiple statements in a single command, that must just be an ‘addition’ for SQL Server.

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

Sidebar

Related Questions

How can I remove the semicolon ( ; ) from a string by using
I'm trying to extract the first user-right from semicolon separated string which matches a
I forget put delimiter directive, some semicolon and was using tsl syntax like [select
I would like to take the data output from the query below and join
I would like to know if i can put a semicolon in a SQL
Can I use any other approach to read the semicolon separated string from .txt
I've got a list of emails and names from Outlook, semicolon delimited, like this:
I just ran into some code that overuse semicolons, or use semicolon for different
Or put another way, why does semicolon insertion fail, leaving the code below broken.
In C#, I can write something like: using (new MyDisposableClass().MethodA()); The semicolon causes a

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.