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?
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.
The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.
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.
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.
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:
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With