ORA-00911 Error Message

Some Oracle errors can seemingly have a million different reasons as to why they occur. The ORA-00911 message would definitely fall into this category. The message, described as an invalid character error, typically is the result of a common syntax mistake.

The cause, according to Oracle docs, can be from starting identifiers with ASCII (American Standard Code) that are not letters or numbers. It is also noted that $, #, and _ are permitted past the first character; that identifiers enclosed in double quotes may contain any characters other than double quotes; and lastly, that alternative quotes cannot use spaces, tabs or carriage returns as delimiters (a separate region of text). With that said, since ORA-00911 is such a common problem with so many potential causes and solutions, let us cover some of the more prevalent fixes to this error.

The first type of ORA-00911 we will look at occurs when attempting to use a special character in an SQL WHERE clause (used to filter results from a particular statement, such as SELECT or UPDATE). If the value is not surrounded by single quotations, the error message will be thrown. For instance, if you have the WHERE clause ‘distributor_name = ?;’, an ORA-00911 will appear. You will need to adjust by placing the end of the clause (the question mark) in quotes (‘distribute_name = ‘?”).

The error message can also result from copying and pasting SQL language into Oracle from another program. The ORA-00911 message may be prompted when this is done, due to non-printable characters from foreign programs not registering with Oracle. The easiest fix for this is to simply retype the SQL content as opposed to pasting, and then trying once again to execute it.

There are also numerous simple syntax errors that can throw an ORA-00911. One problem that can arise is inserting an extra semi-colon to the end of a query. This can easily happen when switching between new programming and copy and pasting from another program. This concept is furthered when accidentally adding an additional semi-colon to an ‘execute immediate’ query, or by adding this character to end a query executing from a program language such as java.

As seen by the set of examples above, an key practice that you should adopt while working in Oracle is being completely aware of when, what and how you are copying and pasting between programs. It can be all too easy to unknowingly string together invalid bits of code simply by writing part of a query, getting distracted, and then copying and pasting directly into the program. Familiarizing yourself with the purpose of semi-colons in Oracle can also go a long way in preventing ORA-00911 errors. If you find that you are uncertain about the proper SQL language to use in Oracle or how to appropriately end a query, you can always speak with an Oracle consultant on how to better familiarize yourself with the dynamics of properly programming an Oracle database.


Submit your question