ORA-00900: invalid SQL statement- when run a procedure in oracle 10g

93,196

Solution 1

Just noticed a detail in your question. You press run button. Thus, you must be using an IDE.

You cannot use execute in IDEs - it is an sql*plus command. It might work in Oracle SQL Developer though, but I wouldn't use it there anyway;

Try

begin
  exam;
end;

Solution 2

See: Syntax error while trying to call an Oracle package using ODBC in C#

You have to put "{" and "}" before the command. Example:

    processListCmd.CommandType = CommandType.StoredProcedure;
    processListCmd.CommandText = "{ call rep_invnr_proclist }";
    processListCmd.ExecuteNonQuery();
Share:
93,196
kumar
Author by

kumar

Updated on July 09, 2022

Comments

  • kumar
    kumar almost 2 years

    I am using Oracle 10g database and trying to run a procedure using SQL commands.

    create or replace procedure "exam" is
    begin
      DBMS_OUTPUT.PUT_LINE('Test');
    end;
    

    Then click on Run button. It shows: "procedure created".

    When I try to execute it using:

    execute exam;
    

    then click on Run button, it shows:

    ORA-00900: invalid SQL statement
    

    Thanks for your help.

  • kumar
    kumar over 11 years
    when used: create or replace procedure exam is begin DBMS_OUTPUT.PUT_LINE('Test'); end; same error is coming.
  • David Aldridge
    David Aldridge over 11 years
    Must be the way that you're executing it in whatever tool you're using then. Does it work in SQL*Plus? If not, you may be executing it as SQL instead of as a procedure call.
  • Kirill Leontev
    Kirill Leontev over 11 years
    if you quote your procedure name, then you should also quote procedure call. if you do not - don't quote in both places.
  • Kirill Leontev
    Kirill Leontev over 11 years
    try create or replace exam... , execute exam; (no quotes)
  • Line
    Line almost 4 years
    the question is not related to C#
  • Line
    Line almost 4 years
    that should be rather a comment, it does not provide the solution in my opinion
  • Michael Kremser
    Michael Kremser almost 4 years
    @Line You are absolutely right! Probably I got confused with too many browser tabs opened and picked the wrong tab when answering.
  • Magnus Reftel
    Magnus Reftel about 3 years
    Actually, this may be the correct answer. Since, as @kirill-leontev pointed out, @kumar seems not to be using SQL*Plus, using { call ... } instead of exec ... should work better.