Ошибка ora 00936 missing expression oracle
In my previous article, I have explained about the most common errors in Oracle. In This article, I will try to explain another most common error, which has been searched approximately 15000 times in a month by DBAs and developers. When you forget the actual syntax of the oracle select statement then the ORA-00936 missing expression error will come. While working with databases I have frequently faced ORA-00936: missing expression and struggled to solve and debug this issue. This kind of error will occur when user miss the syntax of SQL expression.
ORA-00936: missing expression is very common oracle error occurred due to the syntax of oracle statement.
Missing FROM
This error can also occur if you don’t have a FROM keyword in your SELECT statement.
For example, this query will display an error:
There is no FROM clause in this query, so you’ll get an error.
Correct the query to add the FROM clause, so it knows which table to query.
ORA-00936 in INSERT Statement
Just like the UPDATE statement, you can also get an ORA-00936: missing expression in an INSERT statement.
The same steps can be taken:
- Check that you have all of the required keywords.
- Check there are no extra commas
- Check that the number of values and the number of columns are the same
- If you’re using a subquery inside the INSERT statement, then ensure that subquery has all the right keywords and no extra commas as mentioned earlier
So, that’s how you resolve the ORA-00936 error in your SQL query. If you have any questions on this error, leave a comment below.
Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!
ORA-00936 Cause
The error you’ve gotten is this:
Oracle’s official “cause and action” that appears along with the error is:
Cause: A required part of a clause or expression has been omitted. For example, a SELECT statement may have been entered without a list of columns or expressions or with an incomplete expression. This message is also issued in cases where a reserved word is misused, as in SELECT TABLE.
Action: Check the statement syntax and specify the missing component.
So, in summary, the query is missing some clause that it needs in order to run.
Cause of ORA-00936 : missing expression
This Oracle error is mainly related to the SQL SELECT statements. One obvious reason is select column list is missing or expressions in the selected columns are incomplete.
Missing Columns
The ORA-00936 error often occurs when you leave out the columns in the SELECT clause.
This is because you need to list the column names after the word SELECT and before the word FROM.
This query should work:
To view full details, sign in with your My Oracle Support account.
Remove Commas
Sometimes you have all of the right keywords, but you’re still getting the ORA-00936: missing expression error.
For example this query gives an error:
The reason for this is because there is a comma after the final column “last_name”, and then there is the FROM keyword.
Commas should only be used when you want to specify another column or table, and not before a keyword like we have in this example.
To correct it, remove the comma.
Check list to run to resolve the ORA-00936 missing expression error
(1) It happens when you forget to list the column in the select statement
The correct way would be list the column you want to select
(2) We sometimes makes mistake in the usage of Distinct statement. Following statement will fail with ORA-00936
Having two distinct clause does not make sense and give error
distinct can be used in the starting only
So correct statement would be
(3) This error is caused when part of the expression is omitted , some examples are
** operators works in PLSQL but not in SQL, We need to use Power function for it, So correct way would be
(4) Another example
Here you forget to mention column name after the concatenation operator, the correct SQL would be
(5) When you add extra commas in the list of column
So we need to double check the SQL statement when we hit this error and make sure we are doing the common mistake
(6) This error will also come if you omit the From in the SQL statement
Here we missed to mention the from clause.SELECT statement has three parts: to wit: “SELECT->FROM->WHERE
You can omit where clause but select and from are necessary
(7) It can also occurs in insert statement like below
We don’t need values as in this statement
(8) We can sometimes mix up user-defined functions and Oracle functions, and doing so can lead to confused syntax that would result in an error message.So avoid them
In nutshell, ORA-00936 missing expression can be resolved by carefully checking your SQL statement.
Did you get an ORA-00936: missing expression error? Learn what it means and how to resolve it in this article.
Why ORA-00936 error will come?
Some Oracle mistakes are not nearly as intimidating to resolve, as the error message would seem to indicate. The ORA-00936 is the perfect example of such a case. This error provides an excellent case where thinking too hard about the answer will cost you far more time and effort than needed.
Reason for this error:
The ORA-00936 message is a missing expression error in Oracle. That entire ‘missing expression’ means is that when attempting to operate a query, a particular part of the clause necessary for it to function was omitted in the text. Stated simply, you left out an important chunk of what you were trying to run. This is most common error occurred during the syntax of SQL statement. If user failed to write or omit something in SQL query then ‘Missing Expression’ error will come.
Missing Information in Select Statement:
If user forgets to write the columns in the select statement then missing expression error will come.
Example:
Select * from Employee;
Select from Employee; —Error of missing expression will come.
From Clause is Omitted:
If user forgets to write the ‘from clause’ in select statement then missing expression error will come.
ORA-00936 Error Message
Some Oracle mistakes are not nearly as intimidating to resolve as the error message would seem to indicate. The ORA-00936 is the perfect example of such a case. This error provides an excellent case where thinking too hard about the answer will cost you far more time and effort than needed.
The ORA-00936 message is a missing expression error in Oracle. All that ‘missing expression’ means is that When attempting to operate a query, a particular part of the clause necessary for it to function was omitted in the text. Stated simply, you left out an important chunk of what you were trying to run. This can happen fairly easily, but provided below are two examples that are the most common occurrence of this issue.
The first example is the product of missing information in a SELECT statement, which triggers the vast majority of ORA-00936 errors. This occurs when entering SELECT on the first line, but then failing to reference the list of columns following the SELECT. If you just enter ‘SELECT’ on line one, and then ‘FROM abc;’ on line two, the ORA-00936 message will be prompted. To fix this, go back and choose a column to input after SELECT so that line one looks something like ‘SELECT distributors_name, distributors_location’, with line two remaining the same. This will correct the error and allow the SELECT statement to process.
Conversely, the error can happen in the latter half of a SQL statement. If the FROM clause within the statement is omitted, the error message will be thrown. You will need to look back at the syntax of the statement and make sure that for items such as SELECT statements, the next line includes a FROM clause (such as ‘FROM list_of_suppliers’) so that the SELECT clause knows where to be triggering information from within the database.
The ORA-00936 error can be prevented by double-checking instances of SQL clauses and making sure that all statements are derived from the proper syntax. This, of course, extends beyond just SELECT statements but also FROM and WHERE statements as well (or any other clause meant to trigger a query). Be positive that any Oracle functions used are spelled out properly, and keep tabs of user-defined functions. It can be easy to mix up user-defined functions and Oracle functions, and doing so can lead to confused syntax that would result in an error message. The representatives at a licensed Oracle consultant firm can work with you to make sure that you understand the difference between these types of functions and have proper knowledge of the individual functions that come pre-equipped with Oracle database software.
3 thoughts on “ORA-00936: missing expression Solution”
I see an issue with my Oracle queries, but I don’t know why:
1. This one works
SELECT contact_id as id, CONTACTS.* from CONTACTS WHERE ROWNUM
2. This one fails, with the error SQL Error: ORA-00936: missing expression
00936. 00000 – "missing expression"
SELECT contact_id as id, * from CONTACTS WHERE ROWNUM
Hi Xiao, it could be because of the use of *. Perhaps Oracle thinks that if you use * with other columns you need to specify the table name as well.
ORA-00936: missing expression
When using this query
UPDATE RECEIVED_MAILS SET EVENT_NAME = @pEventName WHERE SENDER = @pSender AND RECIPIENT= @pRecipient AND SUBJECT = @pSubject AND MESSAGE = @pMessage.
ORA-00936 in UPDATE Statement
If you’re getting an ORA-00936: missing expression in an UPDATE statement, then the same steps can be taken:
- Check that you have all the keywords that are required (UPDATE, SET)
- Check there are no extra commas where there shouldn’t be.
- If you’re using a subquery inside the UPDATE statement, then ensure that subquery has all the right keywords and no extra commas as mentioned earlier
Leave a Comment Cancel Reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Ben Brumm
DatabaseStar
NO TIME TO READ CLICK HERE TO GET THIS ARTICLE
Example:
Select * from Employee;
Select * Employee; —Missing Expression error will come
As I have explained that missing expression error will come due to the bad syntax of ‘Select statement’ user needs to check the select statement is properly written or not. While working with huge queries then it is not easy for the user to find out where the actual error is. So finding out where the error is coming is important.
Resolution 1:
Example :
It will fire that error so user needs to check the columns in Employee table using following statement:
Desc Employee;
Select Employee_Name,Employee_Number from Employee;
Resolution 2 :
Add from Clause in select statement
User needs to add ‘From’ clause at proper place in select statement.
Resolution Query :
So these kind of errors are very easy to solve just user needs to concentrate on syntax of select statement.
On Oracle Applications 12.2.3 version, Patch Application Issues, when attempting to adop phase=prepare, the following error occurs:
The issue can be reproduced at will with the following steps:
1. Fresh install multi-node
2. In the process to upgrade to 12.2.3
3. adop phase=prepare
The issue has the following business impact:
Due to this issue, users cannot continue with the upgrade
Error in prepare phase when run adop:
[STATEMENT] [END 2014/04/02 12:33:42] Running AutoConfig
[STATEMENT] Content in remote input file :
[STATEMENT] Content in remote input file : /DEV/fs1/EBSapps/appl/ad/12.0.0/bin/adconfig.sh contextfile=/fs2/inst/apps//appl/admin/.xml log=/DEV/fs_ne/EBSapps/log/adop/2/prepare_20140402_121445//adconfig.log>
[STATEMENT] Executing action in all nodes
Running in Serial
xml output = //fs1/EBSapps/appl/admin/_BALANCE/log/remote_execution_result.xml
*******FATAL ERROR*******
PROGRAM : (//fs1/EBSapps/appl/ad/12.0.0/bin/adzdoptl.pl)
TIME : Wed Apr 2 12:34:51 2014
FUNCTION: TXK::SQLPLUS::_doExecute [ Level 3 ]
MESSAGES:
SQLPLUS error: buffer=
SQL*Plus: Release 10.1.0.5.0 - Production on Wed Apr 2 12:34:51 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> SQL> Connected.
SQL> where adop_session_id = 2 and appltop_id = and node_name in ('HOST1','HOST2')
*
ERROR at line 3:
ORA-00936: missing expression
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Changes
Cause
Don't have a My Oracle Support account? Click to get started!
In this Document
Symptoms |
Changes |
Cause |
Solution |
References |
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.
ORA-00936 : missing expression is one of the common error everybody working in Oracle SQL must have faced some time. This generally happens when you omit important thing in the Sql statement i.e you left out an important chunk of what you were trying to run
ORA-00936 Solution
To resolve the ORA-00936 error:
- Check that your column names are all listed correctly in the SELECT clause
- Ensure you have a FROM clause in your SELECT statement. Even if you aren’t selecting from a table, you still need FROM in Oracle SQL, so you could use the DUAL table (LINK)
- Remove any commas that shouldn’t be in your query
Читайте также: