Search code examples
sqldatabaseoracle-databasesql-scripts

How would I fix these "ORA-00933: SQL command not properly ended" "ORA-00923: FROM keyword not found where expected" errors?


This Statement:

SELECT id, units, cost FROM   inventory_list WHERE  cost <= 20;

Gives me:

ORA-00923: FROM keyword not found where expected

While this statement:

SELECT * FROM   items WHERE  ilt_id = 'il010230126' OR ilt_id = 'il010230128';

Gives me:

ORA-00933: SQL command not properly ended


Solution

  • Not sure about this and may be version dependent (below link is for oracle 10g... but you can see on this site

    https://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm

    That cost is an oracle reserved keyword, so it is not wise to use it as a column name.
    If you have no control of the table I think you may be able to surround it in double quotes eg select "COST" to avoid oracle picking it up as a reserved word.

    By default Oracle creates fields in uppercase so the field name will need to be in uppercase unless when the table was created it was forced into different case by surrounding it in Quotes.