ORA-00923: FROM keyword not found where expected

Problem Symptom
While performing a simple select statement it fails with error ORA-00923: FROM keyword not found where expected like below.
SQL> select 48*1024*1024*1024 decimal from dual;
select 48*1024*1024*1024 decimal from dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

Cause of the problem
The ORA-00923 can be caused by two different reasons.
1)Oracle itself expect FROM keyword in the position but it could not find any. Like below,
SQL> select 48*1024 om dual;
select 48*1024 om dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

As no from keyword found so error arises. Oracle expected from in place of keyword dual.

2)The secong cause can sometimes mislead you. Like in case of
SQL> select 48*1024*1024*1024 decimal from dual;
select 48*1024*1024*1024 decimal from dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

Here we see from keyword is in appropriate position but still error occurs. This is because of the reserved keywords in oracle. Oracle database has several reserved keywords and these reserved keywords can't be used as column alias or in column name. As decimal is a reserved keyword so use of it as a column alias raises error ORA-00923.

Solution of the Problem
Use FROM clause in correct position and then either change the name of the column alias so that it can't be a reserved keyword in oracle. Like change decimal to decima as column alias.

SQL> select 48*1024*1024*1024 decima from dual;
DECIMA
----------
5.1540E+10

Or, if you use reserved keywords then use it within double quotes. Like,
SQL> select 48*1024*1024*1024 "decimal" from dual;
decimal
----------
5.1540E+10

Comments

Popular posts from this blog

How to make partitioning in Oracle more Quickly

Copy files between Unix and Windows with rcp