Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "ORA-00933: SQL command not properly ended" on Select with ODBC Command

I'm trying to execute a query against an Oracle DB using ODBC in .NET and am getting the following error:

ORA-00933: SQL command not properly ended

However, the SQL statement is definitely correct, and I can execute it successfully from Oracle SQL Developer. The query itself looks like this:

SELECT * FROM TABLE(SCHEMA.PKG.SPNAME('PARAMS'));

Another simple query works fine:

SELECT COUNT(*) FROM SCHEMA.MYTABLE

It looks like something with the former, where it's using a package in the query and causing something to break. The error indicates that it's not properly ended, but it has a semi-colon and correct braces, so it seems something else is going on.

If I remove the trailing semi-colon, I get an error with no message.

My C# code is basic and looks like this:

using (var connection = new OdbcConnection(connectionString))
{
    using (var command = connection.CreateCommand())
    {
        command.CommandText = commandText;

        connection.Open();
        var result = command.ExecuteScalar();
        connection.Close();

        Console.WriteLine(result);
    }
}

When using the Oracle library for .NET, it works when I remove the trailing semi-colon. If I keep that in place, the same error about the SQL command not being properly ended comes up.

It seems like this query should work with ODBC. Is there anything I need to differently to get it working, or is using the Oracle Managed Data Provider the only way?

like image 202
Mun Avatar asked Oct 21 '15 21:10

Mun


People also ask

How do I fix Ora 00933 SQL command not properly ended?

To correct this issue, simply go back to the end of the phrase and remove the ORDER BY clause. Be sure to go back to the line prior to the ORDER BY clause and re-insert the statement-ending semi-colon. Another case where the ORA-00933 can occur is when attempting to include an ORDER BY clause with a DELETE statement.

What is the use of Where clause in SQL?

The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.

Is not a group by expression?

ORA-00979 “ Not a GROUP BY expression ” is an error issued by the Oracle database when the SELECT statement contains a column that is neither listed in GROUP BY nor aggregated. This error message can be confusing to beginners.

Why am I getting an “ora-00933 SQL command not properly ended” error?

You'll get them for Oracle, SQL Server, MySQL, and PostgreSQL. Print them or use them as an easy reference. If you’re getting an “ORA-00933 sql command not properly ended” on INSERT, then it could be because: You have a JOIN keyword (such as INNER JOIN, LEFT JOIN) in the query.

What is the error when running a report against an oracle?

The following error occurs when running a report against an Oracle database: DMS-E-GENERAL, A general exception has occurred during operation 'prepare request' ORA-00933 SQL command not properly ended. 1. If you are using type-in SQL with date prompts you may also receive this error:

What is the root cause of ora-00933?

ORA-00933 is straightforward error might come because of inappropriate use of any SQL clause. ORA-00933 error is very common error, which will come because of using the SQL clause in inappropriate syntax. There is no another root cause of this error.

Why is MY SQL query not ending properly?

If you’re getting an “ORA-00933 sql command not properly ended” on INSERT, then it could be because: You have a JOIN keyword (such as INNER JOIN, LEFT JOIN) in the query. You have an ORDER BY in the query.


1 Answers

From my experience, I have noticed several instances where a semicolon will break the query, such as JasperSoft Studio and the cx_Oracle Python module. I know very little about ODBC vs OracleDataClient, but I would imagine this is a similar situation.

like image 153
McGlothlin Avatar answered Oct 22 '22 11:10

McGlothlin