// Oracle error reference

ORA-00921: unexpected end of SQL command

The statement stops before it is complete, for example a WHERE with no condition or SQL text cut off when it was built or copied.

Error code
ORA-00921
Category
Syntax and SQL statements
Error message
unexpected end of SQL command

What it means

ORA-00921 means Oracle reached the end of the statement while it still expected more, such as a condition after WHERE or a value after =.

Common causes

  • Dynamic SQL that ends with WHERE or AND because the last condition was empty.
  • A statement truncated by a client, a variable size limit or a copy and paste.

How to fix it

  1. Print the final SQL text and complete the clause that is cut off.

  2. When building conditions in code, add AND only between existing conditions, or start with WHERE 1 = 1.

Related errors

More syntax and sql statements errors

The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.

// fewer errors, faster fixes

Work on Oracle in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.